RPC_C_AUTHN_LEVEL_DEFAULT, RPC_C_IMP_LEVEL_IMPERSONATE, &caid, EOAC_NONE);
pRSL->Methods();
RPC_C_AUTHN_LEVEL_DEFAULT, RPC_C_IMP_LEVEL_IMPERSONATE, &caid, EOAC_NONE);
pAccount->Deposit(x);
hr = CoInitialize(NULL);
ASSERT(SUCCEEDED(hr));
MULTI_QI qi;
qi.pIID = &IID_ICRemoteTime;
qi.hr = NULL;
qi.pItf = NULL;
COAUTHIDENTITY authidentity;
authidentity.User = L"administrator"; ////你机子的帐号
authidentity.UserLength = wcslen(authidentity.User);
authidentity.Domain = NULL;
authidentity.DomainLength = 0;
authidentity.Password = L""; ////密码
authidentity.PasswordLength = wcslen(authidentity.User);
authidentity.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
COAUTHINFO authinfo = {-1, 0, 0, RPC_C_AUTHN_LEVEL_DEFAULT,
RPC_C_IMP_LEVEL_IMPERSONATE, &authidentity, 0};
COSERVERINFO servInf;
servInf.dwReserved1 = NULL;
servInf.dwReserved2 = NULL;
// servInf.pAuthInfo = NULL;
servInf.pAuthInfo = &authinfo;
USES_CONVERSION;
servInf.pwszName = L"127.0.0.1";
hr = CoInitializeSecurity(NULL, -1, NULL, NULL,
RPC_C_AUTHN_LEVEL_NONE, RPC_C_IMP_LEVEL_IDENTIFY, NULL, EOAC_ACCESS_CONTROL, NULL);
ASSERT(SUCCEEDED(hr));
hr = CoCreateInstanceEx(CLSID_CRemoteTime, NULL, CLSCTX_REMOTE_SERVER, &servInf, 1, &qi);
if (FAILED(hr))
{
TRACE(_T("CoCreateInstanceEx failed"));
return false;;
}
if (FAILED(qi.hr))
{
TRACE(_T("Failed to connect to server"));
return false;;
}
//通过IUnkonwn指针去查询接口指针,返回IAccount指针
RPC_C_AUTHN_LEVEL_NONE, RPC_C_IMP_LEVEL_IDENTIFY, NULL, EOAC_NONE, NULL);
COAUTHIDENTITY us;
us.User = m_strName.AllocSysString();
us.UserLength = wcslen(us.User);
us.Password = m_strPassword.AllocSysString();
us.PasswordLength = wcslen(us.Password);
us.Domain = m_strDomain.AllocSysString();
us.DomainLength = wcslen(us.Domain);
us.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
COAUTHINFO auth;
auth.dwAuthnSvc = RPC_C_AUTHN_WINNT;
auth.dwAuthzSvc = RPC_C_AUTHZ_NONE;
auth.pwszServerPrincName = NULL;
auth.dwAuthnLevel = RPC_C_AUTHN_LEVEL_CONNECT;
auth.dwImpersonationLevel = RPC_C_IMP_LEVEL_IMPERSONATE;
auth.dwCapabilities = EOAC_NONE;
auth.pAuthIdentityData = &us;
MULTI_QI qi;
CComBSTR bstr = strComputer;
LPWSTR name = bstr.m_str;
si.dwReserved1 = 0;
si.pwszName = name;
si.pAuthInfo = m_bAccess ? &auth : NULL;
si.dwReserved2 = 0;
IID iid = __uuidof(m_pIRemoteControl);
qi.pIID = &iid;
qi.pItf = NULL;
do
{
hr = CoCreateInstanceEx(__uuidof(RemoteControl), NULL, CLSCTX_SERVER, &si, 1, &qi);
if(FAILED(hr) || FAILED(qi.hr))
break ;
m_pIRemoteControl = (IRemoteControl *)qi.pItf;
}while(0);
RPC_C_AUTHN_LEVEL_NONE, RPC_C_IMP_LEVEL_IDENTIFY, NULL, EOAC_NONE, NULL);
COAUTHIDENTITY us;
us.User = m_strName.AllocSysString();
us.UserLength = wcslen(us.User);
us.Password = m_strPassword.AllocSysString();
us.PasswordLength = wcslen(us.Password);
us.Domain = m_strDomain.AllocSysString();
us.DomainLength = wcslen(us.Domain);
us.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
COAUTHINFO auth;
auth.dwAuthnSvc = RPC_C_AUTHN_WINNT;
auth.dwAuthzSvc = RPC_C_AUTHZ_NONE;
auth.pwszServerPrincName = NULL;
auth.dwAuthnLevel = RPC_C_AUTHN_LEVEL_CONNECT;
auth.dwImpersonationLevel = RPC_C_IMP_LEVEL_IMPERSONATE;
auth.dwCapabilities = EOAC_NONE;
auth.pAuthIdentityData = &us;
MULTI_QI MultiQi={&IID_IUnknown,NULL,NOERROR};
CComBSTR bstr = strComputer;
LPWSTR name = bstr.m_str;
si.dwReserved1 = 0;
si.pwszName = name;
si.pAuthInfo = m_bAccess ? &auth : NULL;
si.dwReserved2 = 0;
hr = CoCreateInstanceEx(__uuidof(RemoteControl), NULL, CLSCTX_SERVER, &si, 1, &MultiQi);
if(FAILED(hr))
{
MessageBox("创建对象实例失败!");
return;
}
//通过IUnkonwn指针去查询接口指针,返回IAccount指针
pUnknown = (IUnknown *) MultiQi.pItf;
hr = pUnknown->QueryInterface(IID_IAccount,(void**)&pAccount);
{
MessageBox("没有查找的接口指针!");
return false;
}
373



被折叠的 条评论
为什么被折叠?



