我有Win32 exe,我正在尝试从中提升COM dll(UTL :: _ RegistryUtils).因为它会写入HKLM位置,所以我不想在提升模式下运行整个应用程序.
类似于以下内容:-
UTL :: _ RegistryUtils * pRegUtils = NULL;
HWND hnd = GetActiveWindow();//(或NULL)
hr = CoCreateInstanceAsAdmin(hn d ,UTL :: CLSID_RegistryUtils,UTL :: IID__RegistryUtils,(void **)& pRegUtils);
if(FAILED(hr)){
> HRESULT CoCreateInstanceAsAdmin(HW ND hwndMain,__in REFCLSID rclsid,__in REFIID riid,__deref_out void ** ppv)
{
MonikerSize + CLSIDSize ];
StringFromGUID2(rclsid,wszCLSID,ARRAYSIZE(wszCLSID));
HRESULT hr = StringCchPrintf(wszMoniker 名称,ARRAYSIZE(wszMonikerName), MonikerName,wszCLSID);
如果(FAILED(hr))
返回hr; bo,0,sizeof(bo));
bo.cbStruct = sizeof(bo);
bo.hwnd = hwndMain;
bo.dwClassContext = CLSCTX_LOCAL_SERVER;
hr = CoGetObject(wszMonikerName ,&bo,riid,ppv);
/*
此处"hr"获得错误值:"0x80080016激活要求应用程序的RunAs值为激活为激活器"
* /hr;
}
我做了所有注册表设置,例如:
HKEY_LOCAL_MACHINE \ SOFTWAR E \ Classes
{
AppID \ CommonUtils.dll
{
(默认):REG_SZ = null
AppID:REG_SZ ='{6BCFB187-C1DD-4807-96AD- F91AB4AB08 AC}'
}
AppID \ { 6BCFB187-C1DD-4807- 96AD-F91AB 4AB08AC}
{
(默认):REG_SZ ='CommonUtils'
AccessPermission:REG_BINARY = te:REG_SZ =``
}
CLSID \ {6BCFB187-C1DD-4807- 96AD-F91AB 4AB08AC}
{
(默认):REG_SZ =' CommonUtils'
AppID:REG_SZ ='{6BCFB187-C1DD-4807-96AD- F91AB4AB08 AC}'
LocalizedString:REG_SZ ='@C:\您的\路径\此处\公用 Utils.dll, -101'
仰角
{默认值:REG_SZ = null
启用:REG_DWORD = 1
}
}
>}
UTL :: CLSID_RegistryUtils是简单的VB COM dll.我正在VS2008中开发,平台是Vista.
有人可以帮助我解决此错误吗?
这篇关于“激活要求应用程序的RunAs值是Activate As Activator".提升VB COM DLL时出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!