What is the C ++ equivalent for GetObject in JavaScript and VBScript?

What is the C ++ equivalent for GetObject

in JavaScript and VBScript ?

The closest match I found to my question is:

http://codewiz51.blogspot.com/2008/06/vb-script-getobject-c-api-cogetobject.html

However, the sample is using an unused interface and requests to IUnknown

return null. Does anyone have an example that works?

0


source to share


4 answers


I figured out the question. The object I wanted to get was

winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv

I mistook \\ for the descent. In C ++, the correct query is:



::CoGetObject(L"winmgmts:{impersonationLevel=impersonate}!\\\\.\\root\\default:StdRegProv", NULL, IID_IUnknown, (void**)&pUnk);

Thank:)

+2


source


The article you linked is correct. You may have specified an incorrect interface ID, or the display name may be incorrect. You should check the return value from the call CoGetObject

.



+1


source


If the IUnknown query returns NULL, the object does not have that name. Every COM object implements IUnknown.

0


source


Have you initialized COM before making any COM calls?

Find CoInitializeEx.

0


source







All Articles