dienjd
26th March 2007 19:34 UTC
CoFreeUnusedLibraries call in InstallLib
In http://nsis.sourceforge.net/Docs/AppendixB.html#B.2.3 under LIBRARY_COM it says "...to call CoFreeUnusedLibraries after registration" and the Library.nsh code shows this.
MSDN:
CoFreeUnusedLibraries
Unloads any DLLs that are no longer in use and that, when loaded, were specified to be freed automatically.
Is there a reason this call is only made after registration? Why isn't it called before installation/registration also? I don't have experience with CoFreeUnusedLibraries, so I'm trying to understand its usage, but from the description it seems like you'd want to call it before installation/registration.
Thanks.
kichik
27th March 2007 20:46 UTC
Calling it before unregistration will have no meaning because the unregistered DLL is not loaded at that stage. The idea behind this call is unloading the DLL so it can be deleted after it's unregistered.
Calling it in the registration process is probably useful only for freeing unused memory. In that case as well it wouldn't make any sense calling it before the DLL was even loaded.
See the original thread for more details.
dienjd
27th March 2007 21:36 UTC
Thanks, I didn't find that older thread when researching.
I had in mind the scenario of an overinstall. For example, a COM DLL is already installed and was being used. The process using it stopped using it, but it had not been unloaded by the time you overinstall. It seemed like CoFreeUnusedLibraries or CoFreeUnusedLibrariesEx would possibly allow you to overinstall the DLL immediately without having to install it as a temp file and rename on reboot. If the DLL is actively being used, the API call would not help...this would all depend on the timing.
I may be (make that 'probably am') completely wrong about this, so I was seeing what others thought about it.
kichik
27th March 2007 21:52 UTC
It only frees DLLs of the current process, not all processes on the system.
dienjd
27th March 2007 21:55 UTC
ah, that makes sense. Thanks for the clarification :)