描述:
从网上下了一段代码如下:测试不行,CoCreateInstanceEx返回值指示失败,也不知利用哪个函数可将失败原因转换出来(GetLastError()不行)
UUID id=__uuidof(IControl);
IControl *ICtrli;
COSERVERINFO serverInfo;
ZeroMemory(&serverInfo, sizeof(COSERVERINFO));
COAUTHINFO athn;
ZeroMemory(&athn, sizeof(COAUTHINFO));
// Set up the NULL security information
athn.dwAuthnLevel = RPC_C_AUTHN_LEVEL_NONE;
athn.dwAuthnSvc = RPC_C_AUTHN_WINNT;
athn.dwAuthzSvc = RPC_C_AUTHZ_NONE;
athn.dwCapabilities = 0;//EOAC_NONE;
athn.dwImpersonationLevel = RPC_C_IMP_LEVEL_IMPERSONATE;
athn.pAuthIdentityData = NULL;
athn.pwszServerPrincName = NULL;
serverInfo.pwszName = L"\\\\ServerComputerName";
serverInfo.pAuthInfo = &athn;
serverInfo.dwReserved1 = 0;
serverInfo.dwReserved2 = 0;
MULTI_QI qi = {&id, NULL, S_OK};
hr=CoCreateInstanceEx(clsid, NULL,CLSCTX_LOCAL_SERVER | CLSCTX_REMOTE_SERVER, &serverInfo, 1, &qi);
//hr=CoCreateInstance(clsid,NULL,CLSCTX_LOCAL_SERVER,__uuidof(IControl),(LPVOID*)&ICtrli);
if(FAILED(hr)){//这个地方总是失败,但又不知何因?