Is it possible to use COM Object from DLL without register in C++ not managed code?
3 Answers
10
votes
7
votes
2
votes
Say, the COM DLL needs to be registered, but the application doesn't have admin access rights. Here is an easy hack to register the DLL under HKEY_CURRENT_USER, which doesn't require admin rights:
- Use
LoadLibraryto load the COM DLL. - Call
GetGetProcAddressto get the address ofDllRegisterServer. - Call
RegOverridePredefKeyto make the temporary registry redirects:HKEY_LOCAL_MACHINEtoHKEY_CURRENT_USERandHKEY_CLASSES_ROOTtoHKEY_CURRENT_USER\Software\Classes. - Call
DllRegisterServerobtained in step 2. - Reverse the registry redirects.
- Use the COM server as usual, it's now registered under
HKEY_CURRENT_USER.