2013年11月18日 星期一

CoInitializeSecurity call fails with error code RPC_E_TOO_LATE

In the VC++ MFC MDI, the  CoInitializeSecurity call fails with error code RPC_E_TOO_LATE

1. We can check (http://msdn.microsoft.com/en-us/library/windows/desktop/aa394603(v=vs.85).aspx) for WMI troubleshooting.

2. There is the example code in the http://support.microsoft.com/kb/948829

3. The code here (http://www.codeproject.com/Articles/216077/Making-Your-Cplusplus-Code-Robust) can help us solve the WMI execquery problem.

4. Please check http://msdn.microsoft.com/en-us/library/windows/desktop/aa393609(v=vs.85).aspx.  The key point is CoSetProxyBlanket function.

hres = CoSetProxyBlanket(
   pSvc,                        // Indicates the proxy to set
   RPC_C_AUTHN_WINNT,           // RPC_C_AUTHN_xxx
   RPC_C_AUTHZ_NONE,            // RPC_C_AUTHZ_xxx
   NULL,                        // Server principal name 
   RPC_C_AUTHN_LEVEL_CALL,      // RPC_C_AUTHN_LEVEL_xxx 
   RPC_C_IMP_LEVEL_IMPERSONATE, // RPC_C_IMP_LEVEL_xxx
   NULL,                        // client identity
   EOAC_NONE                    // proxy capabilities 
);

沒有留言:

張貼留言