本文介绍了“激活要求应用程序的RunAs值是Activate As Activator".提升VB COM DLL时出现错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有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.

有人可以帮助我解决此错误吗?

推荐答案

http://blogs.msdn.com/vistacompatteam/archive/2006/09/28/CoCreateInstanceAsAdmin-or-CreateElevatedComObject-sample.aspx


这篇关于“激活要求应用程序的RunAs值是Activate As Activator".提升VB COM DLL时出现错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-23 02:11