I am trying to access the stdregprov using the COM interface using C++. I am
unsuccessful in invoking the Put method that initializes the variables before
calling the Exec method of IWbemClassObject.
The code is as follows
BSTR bsClassName = SysAllocString(L"Root\\default:StdRegProv");
BSTR bsMethodName = SysAllocString(L"GetStringValue");
pClass = NULL;
hres = pSvc->GetObject(bsClassName, 0, NULL, &pClass, NULL);
pInParamsDefinition = NULL;
hres = pClass->GetMethod(bsMethodName, 0, NULL, &pInParamsDefinition);
pClassInstance = NULL;
hres = pInParamsDefinition->SpawnInstance(0, &pClassInstance);
VARIANT var;
BSTR ArgName = SysAllocString(L"hDefKey");
// set registry root
VariantClear(&var);
var.vt = VT_I4;
var.lVal = 0x80000002;
hres = pClassInstance->Put(ArgName, 0, &var, 0);
// set registry key
VariantClear(&var);
var.vt = VT_BSTR;
var.bstrVal =
SysAllocString(L"SYSTEM\\CurrentControlSet\\Contro l\\CrashControl");
hres = pClassInstance->Put(L"sSubKeyName", 0, &var, 0);
// set registry key
VariantClear(&var);
var.vt = VT_BSTR;
var.bstrVal = SysAllocString(L"AutoReboot");
hres = pClassInstance->Put(L"sValueName", 0, &var, 0);
VariantClear(&var);
DWORD dwValue = -1;
hres = pSvc->ExecMethod(bsClassName, bsMethodName, 0,NULL, pClassInstance,
&pOutParams, NULL);
Are there any samples to do the something similar