Saturday, April 20, 2013

How to Release a DLL With DLLHost.EXE


1. Create a new callback function in the programming language you are writing the application for. A callback function is one that listens for a specific event to be sent to it, rather than triggering the event itself. The WIN32 API release event is 'WM_RELEASE.' Consult your programming language's WIN32 API documentation for how to create a callback function for this message.
2. Respond to the event by opening DLLHost.EXE with a 'ShellExecute()' or other command to open an application on the system. You will need to open 'C:\Windows\System32\dllhost.exe.' Run the command including the 'hWnd' (window handle) variable of your application as a parameter. So, you would send the open command: 'C:\Windows\System32\dllho.'
3. Process the release of the file when the callback function is triggered. You should free up any resources that make use of it and call the appropriate destructor methods for any functions or classes that required the DLL to operate.