Win32:如何从标准用户使用 RegisterTypeLib API [英] Win32: How to use RegisterTypeLib API from standard user
问题描述
Win32 API 调用 RegisterTypeLib() 用于创建注册类型库所需的注册表项.
The Win32 API call RegisterTypeLib() is used to create the registry keys necessary to register a type library.
不幸的是,在 Windows XP 上,它试图将这些注册表项写入
Unfortunatly, on Windows XP, it tries to write those registry key entries to
HKEY_CLASSES_ROOT\TypeLib
而不是
HKEY_CURRENT_USER\Software\Classes\TypeLib
意味着标准用户将无法运行 ActiveX.
Meaning that a standard user will not be able to run an ActiveX.
2008 年 5 月,Microsoft 发布了Vista 修补程序来更正此问题 - 但问题仍然存在在 Windows XP 上.
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?
使用专为它设计的 API 调用:
Use the API call that is designed for it:
如果你不能修复它,破解它:
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);
推荐答案
您可以使用 RegOverridePredefKey()
API 将 HKEY_CLASSES_ROOT
regtree 映射到 HKEY_CURRENT_USER\软件\类
:
You can use the RegOverridePredefKey()
API to map the HKEY_CLASSES_ROOT
regtree to HKEY_CURRENT_USER\Software\Classes
:
这篇关于Win32:如何从标准用户使用 RegisterTypeLib API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!