The Win32 API call RegisterTypeLib() is used to create the registry keys necessary to register a type library.
Unfortunatly, on Windows XP, it tries to write those registry key entries to
HKEY_CLASSES_ROOT\TypeLib
rather than
HKEY_CURRENT_USER\Software\Classes\TypeLib
Meaning that a standard user will not be able to run an ActiveX.
In May 2008 Microsoft released a hotfix for Vista to correct this issue - but the problem remains on Windows XP.
What's a standard-user friendly developer to do?
Use the API call that is designed for it:
RegisterTypeLibraryForUser()
If you can't fix it, hack it:
//begin hack
HKEY key;
RegOpenKeyW(HKEY_CURRENT_USER, @"Software\Classes", out key);
RegOverridePredefKey(HKEY_CLASSES_ROOT, key);
//do original work
RegisterTypeLibrary(...)
//stop hacking
RegOverridePredefKey(HKEY_CLASSES_ROOT, null);
RegCloseKey(key);
Take a look at this blog entry I wrote. It will registry ATL COM objects into HKCU instead of HKCR using RegOverridePredefKey. You can use the same technique to call RegisterTypeLib and have it properly register under HKCU
Register ATL as Normal User
You can use the RegOverridePredefKey()
API to map the HKEY_CLASSES_ROOT
regtree to HKEY_CURRENT_USER\Software\Classes
:
http://msdn.microsoft.com/en-us/library/ms724901.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With