Question

The unhelpful "Generic Failure" error is thrown from the following line of code, when running in one process, but not in another. I can't figure out what's different between the processes (they both run 32-bit as administrator).

WbemScripting::ISWbemObjectSetPtr hdobjects = services->ExecQuery("Select * from Win32_LogicalDisk","WQL",0x10,NULL);

Any ideas why?

Was it helpful?

Solution

It's because COM security is set differently in each process. This is determined in each process by the startup call to CoInitializeSecurity.

A DLL cannot reset this once it has been called, but can set security for the current Wbem connection with CoSetProxyBlanket.

I couldn't easily figure out how to set this correctly through WbemScripting so I reimplemented with COM calls, much like the extensive example here, only without step 2:

http://msdn.microsoft.com/en-gb/library/windows/desktop/aa390423(v=vs.85).aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top