The ExecMethod fails with 0x80041002 WBEM_E_NOT_FOUND only in Vista.
The code works fine in XP.
// set up to call the SystemRestore::Restore method
BSTR MethodName = SysAllocString(L"Restore");
BSTR ClassName = SysAllocString(L"SystemRestore");
IWbemClassObject* pClass = NULL;
hres = service->GetObject(ClassName, 0, NULL, &pClass, NULL);
IWbemClassObject* pInParamsDefinition = NULL;
hres = pClass->GetMethod(MethodName, 0, &pInParamsDefinition, NULL);
IWbemClassObject* pClassInstance = NULL;
hres = pInParamsDefinition->SpawnInstance(0, &pClassInstance);
// Create the values for the in parameters
VARIANT varCommand;
varCommand.vt = VT_I4;
varCommand.iVal = nRestoreSequenceNumber_;
// Store the value for the in parameters
hres = pClassInstance->Put(L"SequenceNumber", 0, &varCommand, 0);
// Execute Method
IWbemClassObject* pOutParams = NULL;
hres = service->ExecMethod(ClassName, MethodName, 0, NULL, pClassInstance, &pOutParams, NULL);
Any ideas what could be wrong?
Thanks
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 379 |
Nodes: | 16 (2 / 14) |
Uptime: | 19:50:58 |
Calls: | 8,133 |
Calls today: | 6 |
Files: | 13,082 |
Messages: | 5,856,151 |