Windows XP Community - XPHeads



WMI Registry Methods from StdRegProv

microsoft.public.windowsxp.wmi


Reply
  #1 (permalink)  
Old 02-25-2008, 11:48 AM
LChambers
 
Posts: n/a
WMI Registry Methods from StdRegProv
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-
>SpawnInstance(0,



&pClassInstance);


if(SUCCEEDED(hres))
{
VARIANT varCommand;
varCommand.vt = VT_BSTR;
varCommand.bstrVal =
L"SOFTWARE
\Microsoft\Windows\CurrentVersion\Policies\System\ \";


hres =
pClassInstance-



>Put(L"sSubKeyName", 0,



&varCommand, 0);

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


hres = pClassInstance-
>Put(L"sValueName", 0,


&varCommand, 0);


VARIANT lvar;
VariantInit(&lvar);
lvar.vt = VT_BSTR;
lvar.bstrVal = L"Notice";


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

&lvar,
0);


// Execute Method
IWbemClassObject* pOutParams =
NULL;
hres = pSvc-
>ExecMethod(ClassName,



MethodName, 0, NULL, pClassInstance,


&pOutParams, NULL);


if (FAILED(hres))
{
MessageBox("Command


Failed","SetStringValue",MB_OK);
}
else
{
CComBSTR
bstrClassObj;
hres = pOutParams-
>GetObjectText(0,



&(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);
}


Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 02:52 AM.








Design by Vjacheslav Trushkin for phpBBStyles.com.
Powered by vBulletin® Version 3.6.7
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0

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 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74