1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
CComBSTR MethodName(_T("SetDateTime"));
CComBSTR ClassName(_T("Win32_OperatingSystem"));
IWbemClassObject* pClass = NULL;
hres = m_pWbemServices->GetObject(ClassName, 0, NULL, &pClass, NULL);
IWbemClassObject* pInParamsDefinition = NULL;
hres = pClass->GetMethod(MethodName, 0,
&pInParamsDefinition, NULL);
IWbemClassObject* pClassInstance = NULL;
hres = pInParamsDefinition->SpawnInstance(0, &pClassInstance);
if (FAILED(hres))
{
CString szDebug;
szDebug.Format(_T("Erreur Spawn : %X\r\n"),hres);
OutputDebugString(szDebug);
}
//CComBSTR bstrdate(param);
BSTR bstrdate = SysAllocString(L"20090722090000.000000+120");
// Create the values for the in-parameters
VARIANT varCommand;
varCommand.vt = VT_BSTR;
varCommand.bstrVal = bstrdate;
// Store the value for the in-parameters
hres = pClassInstance->Put(L"LocalDateTime", 0,
&varCommand, CIM_DATETIME);
if (FAILED(hres))
{
CString szDebug;
szDebug.Format(_T("Erreur Put : %X\r\n"),hres);
OutputDebugString(szDebug);
}
// Execute Method
IWbemClassObject* pOutParams = NULL;
hres = m_pWbemServices->ExecMethod(ClassName, MethodName, 0,
NULL, pClassInstance, &pOutParams, NULL);
SysFreeString(bstrdate); |
Partager