リモート オブジェクトのインスタンス化にうんざりしています。
dcomcnfg を使用し、すべての Windows 7、同じワークグループ PC に対してアクセスを有効にしました。
CoInitializeEx(0,COINIT_APARTMENTTHREADED);
CoInitializeSecurity(0, -1, NULL, NULL,RPC_C_AUTHN_LEVEL_DEFAULT, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE, NULL);
COAUTHINFO ca = {0};
ca.dwAuthnSvc = RPC_C_AUTHN_WINNT;
ca.dwAuthzSvc = RPC_C_AUTHZ_NONE;
ca.dwAuthnLevel = RPC_C_AUTHN_LEVEL_DEFAULT;
ca.dwImpersonationLevel = RPC_C_IMP_LEVEL_IMPERSONATE;
COAUTHIDENTITY id = {0};
ca.pAuthIdentityData = &id;
id.User = (USHORT*)<username>;
id.UserLength = length;
id.Password = (USHORT*)<password>;
id.PasswordLength = pwdlength;
id.Domain = (USHORT*)L"WORKGROUP";
id.DomainLength = 9;
id.Flags = SEC_WINNT_AUTH_IDENTITY_UNICODE;
COSERVERINFO c = {0};
c.pwszName = L"192.168.10.3";
c.pAuthInfo = &ca;
MULTI_QI res = {0};
res.pIID = &TheIID;
HRESULT hr = CoCreateInstanceEx(TheCLSID,0,CLSCTX_REMOTE_SERVER,&c,1,&res);
常に E_ACCESSDENIED。ところで、このサンプル (http://support.microsoft.com/kb/259011) は動作します。しかし、私はそのソースを見つけることができません。
サーバーは、同じレベルで CoInitializeSecurity() も呼び出します。
Windows XP マシンを対象とする場合、CoCreateInstanceEx() は S_OK を返しますが、サーバーは作成されません。Windows 7 を対象とする場合、E_ACCESSDENIED.
手がかりはありますか?また、作業サンプルでは U+P を使用していません。匿名で電話してみようかな。