Real Geek Forums  

Go Back   Real Geek Forums > Archives > Operating Systems > Windows XP > Windows XP WMI

Notices

Reply

WMI Registry Methods from StdRegProv

 

LinkBack Thread Tools Display Modes
Old 02-25-2008, 11:48 AM   #1 (permalink)
Default 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-
Quote:
>SpawnInstance(0,

&pClassInstance);


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


hres =
pClassInstance-


Quote:
>Put(L"sSubKeyName", 0,

&varCommand, 0);

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


hres = pClassInstance-
Quote:
>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-
Quote:
>Put(L"sValue", 0,
&lvar,
0);


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

MethodName, 0, NULL, pClassInstance,


&pOutParams, NULL);


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


Failed","SetStringValue",MB_OK);
}
else
{
CComBSTR
bstrClassObj;
hres = pOutParams-
Quote:
>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);
}


LChambers
Guest
 
Posts: n/a
Reply With Quote  
Reply

Tags
None

Thread Tools
Display Modes

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

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


Similar Threads

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


All times are GMT. The time now is 11:51 PM.


Powered by vBulletin® Version 3.7.1
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright © 2005 - 2007 RealGeek.com. All rights reserved.

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 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90