I agree with the previous comments about the dangerous global status information, although I can imagine that this might be needed.
I offer a cleaner version of the dirty DR hack that does not lack constancy, as the answer from skamradt:
Very small application:
It has no appearance, it does not appear on the taskbar.
Task number 1: load the DLL
Task number 2: Take it on the command line, run it and wait for it to complete.
Task number 3: unload DLL
Task number 4: Exit.
Installer:
It finds the shortcuts (s) in the main application and changes them so that a small application runs, the original location that the shortcut points to becomes the first parameter.
Results: The DLL remains in memory only as long as the main application is running, but it is not unloaded every time the program unloads it.
Loren pechtel
source share