Component creation fails under UAC admin, works without UAC elevation

天涯浪子 提交于 2020-01-15 11:42:51

问题


I have a .NET COM dll with a custom registration procedure so it gets registered under HKEY_CURRENT_USER\Software\Classes as opposite to HKEY_LOCAL_MACHINE. So there are the following keys (current user is the admin on the Windows 7 PC):

HKEY_CURRENT_USER\Software\Classes\My.ProgId\CLSID
HKEY_CURRENT_USER\Software\Classes\CLSID\{XYZZYZYZYZ-YZYZY-ZYZYZY} etc

If I build a simple C++ client:

hr = CLSIDFromProgID(OLESTR("My.ProgId"), &clsid); 

and run it without UAC elevation (Windows 7), it creates the component successfully. On the other hand, if I run with elevation on, it fails with Invalid class string.

I've inspected with process monitor, when it works it looks for the HKCU\Software\Classes\My.ProgID key and that opens ok. When it fails (elevation on) it looks for HKCR\My.ProgId and errors with NAME NOT FOUND. Opening the registry key manually from classes_root is successful though:

HKEY key;
RegOpenKey( HKEY_CLASSES_ROOT, _T( "My.ProgId"), &key);

Please help! Thanks

来源:https://stackoverflow.com/questions/5649544/component-creation-fails-under-uac-admin-works-without-uac-elevation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!