If your code runs inside another process it is at the mercy of the elevation state of that process. If that process does not run elevated, and explorer does not, then your code in your DLL cannot execute elevated.
Your solution therefore is to create another process to perform the tasks which require elevation. Do that using one of these methods:
- Specify the
requireAdministrator
option forrequestedExecutionLevel
in the application manifest. - Start the process using
ShellExecuteEx
with therunas
verb. - Put the code to be elevated in a COM object and use the COM elevation moniker.