So I’ve been thinking about coding an auto-updater for an audio plugin … here is how I imagine it would work:
1 - on startup, plugin checks for internet access, and points to some remote XML which has a version number.
2 - if the version number in the XML is greater than it’s own version number, it downloads the new plugin DLL and stashes it somewhere.
3 - the program then launches a process that will attempt to copy the stashed DLL and overwrite the current DLL (intuiting the plugins location, since it can vary)
4 - the DLL closes so that the new process can copy (naturally you can’t overwrite a program as it is running)
I imagine the “process” will have to be a separate executable file, probably sitting in the AppData directory.
Sound reasonable? Any gotchas to keep in mind ?
How do you force the host application to quit? Because that’s the only way to unload the old DLL.
I don’t, I just move the (running) DLL to a different location, and move the new one in to it’s place and let the user know that they need to restart the plugin.
I don’t think you can move the running DLL into a different location. As long as any process has that DLL loaded, it can’t be moved/renamed/modified.
The only way this could work is if your DLL is hosting another DLL (so your plugin is really a small host) and then it can properly unload the child DLL, replace it with a newer copy, then load it again. The “host” would not be updated, but once the “host” is debugged and tested well enough, it probably rarely needs to be updated.
So Aaron, did you spend the last 6 years carefully considering the answer to Vinnie’s question before replying?
@reFX I think most OSes will let you move/rename a DLL or executable while it’s running, but not delete it. Try it yourself by renaming an app while it’s running.
Hehehehhe … for some reason, it just came up on my account as recently modified.
And I was like … Woah! Vinn is still around?!
Also - surprising to me … but you certainly can move running DLLs on mac. I think windows may have been a little different … but I haven’t look at this in quite a while.
You can’t move it, rename it or delete on Windows. Linus and Mac are different, but for them you would still need to start the host again.