![]() |
| |||||||
| Notices |
![]() |
| LinkBack | Thread Tools | Display Modes |
| | #1 (permalink) | ||||||
| Hello, I found several examples to use SetStringValue and SetDWORDValue in Default\StdRegProv. They all are in VB language and i'm using C++ in my applications. For example I try to disable UAC on VISTA OS boxes remotly but I have a ReturnValue = 0 each time I try to execute my Method. I think parameters are right but It puts value "3" in the registry entry. Could someone help me ? hres = CoCreateInstance(CLSID_WbemLocator, 0, CLSCTX_INPROC_SERVER, IID_IWbemLocator, (LPVOID *) &ppiWmiLoc); IWbemServices *pSvc = NULL; CComBSTR bstrserv(L"\\\\VISTABOX\\root\\default"); CComBSTR bstrUsername(m_csUserName), bstrPassword(m_csPassword); hres = ppiWmiLoc->ConnectServer(bstrserv, NULL, NULL,0, NULL, 0, 0, &pSvc); if(SUCCEEDED(hres)) { 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); if(SUCCEEDED(hres)) { BSTR MethodName = SysAllocString(L"SetStringValue"); BSTR ClassName = SysAllocString(L"StdRegProv"); IWbemClassObject* pClass = NULL; hres = pSvc->GetObject(ClassName, 0, NULL, &pClass, NULL); if(SUCCEEDED(hres)) { IWbemClassObject* pInParamsDefinition = NULL; hres = pClass->GetMethod(MethodName, 0, &pInParamsDefinition, NULL); if(SUCCEEDED(hres)) { IWbemClassObject* pClassInstance = NULL; hres = pInParamsDefinition- Quote:
&pClassInstance); if(SUCCEEDED(hres)) { VARIANT varCommand; varCommand.vt = VT_BSTR; varCommand.bstrVal = L"SOFTWARE \Microsoft\Windows\CurrentVersion\Policies\System\ \"; hres = pClassInstance- Quote:
&varCommand, 0); varCommand.vt = VT_BSTR; varCommand.bstrVal = L"legalnoticecaption"; hres = pClassInstance- Quote:
VARIANT lvar; VariantInit(&lvar); lvar.vt = VT_BSTR; lvar.bstrVal = L"Notice"; // Store the value for the in parameters hres = pClassInstance- Quote:
0); // Execute Method IWbemClassObject* pOutParams = NULL; hres = pSvc- Quote:
MethodName, 0, NULL, pClassInstance, &pOutParams, NULL); if (FAILED(hres)) { MessageBox("Command Failed","SetStringValue",MB_OK); } else { CComBSTR bstrClassObj; hres = pOutParams- Quote:
&(bstrClassObj.m_str)); USES_CONVERSION; std::string mess(OLE2T(bstrClassObj)); MessageBox(mess.c_str(),"Error message",MB_OK); } } else AfficheErreur(hres); } else AfficheErreur(hres); } else AfficheErreur(hres); } | Guest
Posts: n/a
| ||||||
|
![]() |
| Tags |
| None |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| interface methods? | Hseemoore | Windows XP Movie Maker | 1 | 12-09-2003 02:32 PM |
| interface has too many methods | john | Windows XP Movie Maker | 1 | 10-07-2003 08:18 PM |