R – Win32: How to use RegisterTypeLib API from standard user


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


rather than


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?

Answer 1

Use the API call that is designed for it:


Answer 2

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

//stop hacking
RegOverridePredefKey(HKEY_CLASSES_ROOT, null);

Best Solution

You can use the RegOverridePredefKey() API to map the HKEY_CLASSES_ROOT regtree to HKEY_CURRENT_USER\Software\Classes:

Related Question