title: Anyone made DCOM working with CoCreateInstanceEx in Windows 7
body: <p>I 'm fed up trying to instantiate a remote object.</p>
  
  <p>dcomcnfg used, access enabled to all, Windows 7, same workgroup PCs.</p>
  
  <pre><code>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 = &amp;id;
  id.User = (USHORT*)&lt;username&gt;;
  id.UserLength = length;
  id.Password = (USHORT*)&lt;password&gt;;
  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 = &amp;ca;
  MULTI_QI res = {0};
  res.pIID = &amp;TheIID;
  HRESULT hr = CoCreateInstanceEx(TheCLSID,0,CLSCTX_REMOTE_SERVER,&amp;c,1,&amp;res);
  </code></pre>
  
  <p>Always E_ACCESSDENIED. And by the way, this sample (http://support.microsoft.com/kb/259011) works. But I can't find the source of it.</p>
  
  <p>The server also calls CoInitializeSecurity() with the same levels.</p>
  
  <p>When targetting a Windows XP machine, CoCreateInstanceEx() returns S_OK, but the server isn't created.  When targetting Windows 7, E_ACCESSDENIED.</p>
  
  <p>Any clues?
  Also, the working sample doesn't use U+P. Perhaps I should try an anonymous call?</p>