Re: WMI Methods in C++

Tech-Archive recommends: Fix windows errors by optimizing your registry



Well,

I have another problem, using SetDWORDValue method.

As I had :

// Create the values for the in parameters


varCommand.vt = VT_BSTR;
varCommand.bstrVal = L"toto";


// Store the value for the in parameters
hres = pClassInstance->Put(L"sValue", 0,
&varCommand, 0);

I'd like to set "lValue" of SetDWORDValue method to 0 or 1. But can't
find type of variant to set it ... I tried VT_UINT, VT_I8 and so
on ... but I got always same -2147217403 error ....


varCommand.vt = VT_UINT;
varCommand.uintVal = 1;


// Store the value for the in parameters
hres = pClassInstance->Put(L"lValue", 0,
&varCommand, 0);


Need some help again...


On 5 mar, 01:00, Chris Richards <g...@xxxxxxxxxxxxx> wrote:
You have to set your impersonation level before you can make calls to
WMI. After you call:

hres = ppiWmiLoc->ConnectServer(bstrserv, NULL, NULL, 0, NULL, 0, 0, &pSvc)

You need to call:

hRes = CoSetProxyBlanket(pSvc, RPC_C_AUTHN_WINNT, RPC_C_AUTHZ_NONE,
NULL, RPC_C_AUTHN_LEVEL_CALL, RPC_C_IMP_LEVEL_IMPERSONATE, NULL, EOAC_NONE);

That should get you fixed up (I hope).

Later,
Chris



luke_21 wrote:
For example for that code, I have no error about the execution of
Method, but I have Error code 1346 as Returned Value from
SetStringValue function.
It says that : Either a required impersonation level was not provided,
or the provided impersonation level is invalid. But can't understand
what that could say ....- Masquer le texte des messages précédents -

- Afficher le texte des messages précédents -


.