Simply put: do not do this (i.e. do not force unload it). You will need to list all the processes in which the shell extension is loaded, and then restart them. This is very invasive and frank: bad behavior (for the installer). It also requires special privileges that your installer may not need.
What most people still don't know is that MoveFile
(and MoveFileEx
) can be used to move the DLL or EXE files that are currently being used by a running application.
This is the approach that Windows Installer takes. Have you ever noticed the \Config.msi
folder in the root directory of this drive after installing some .msi
? This folder actually contains (moves and is usually renamed to some unique βtemporaryβ name) source files that were moved but were still in use at that time. Then they are usually assigned for deletion at boot ( MoveFileEx
with MOVEFILE_DELAY_UNTIL_REBOOT
).
You can use the same mechanism in your homebrew installer and transfer the old file that is used in the original location and transfer the other immediately. Any new application instance will use the new shell extension (*), while the old one will continue to be used by any of the running applications that loaded it at one point or another.
(*) I am not 100% sure about this because of the rules that apply to loading DLLs, and do not allow loading modules with the same name under certain circumstances.
source share