Re: Remolty access to the registry with WMI
Eric Baelen <[email protected]> Wed, 5 Oct 2005 16:42:34 +0200
| Newsgroups | gmane.comp.windows.devel.jawin |
|---|---|
| Message-ID | <002901c5c9bb$061d7bb0$1a01070a@nberic> |
Because I receive this:
org.jawin.COMException: 80070057: The parameter is incorrect.
at org.jawin.marshal.GenericStub.dispatchInvoke0(Native Method)
at
org.jawin.marshal.GenericStub.dispatchInvoke(GenericStub.java:201)
at org.jawin.DispatchPtr.invokeN(DispatchPtr.java:587)
at org.jawin.DispatchPtr.invokeN(DispatchPtr.java:555)
Which I don't when I use:
Variant.ByrefHolder names = new Variant.ByrefHolder(new String());
Variant.ByrefHolder types = new Variant.ByrefHolder(new Integer(0));
But I agree this is strange.
Tx
Eric
-----Original Message-----
From: Discussion of Java/Win32/COM integration with Jawin
[mailto:[email protected]] On Behalf Of Christophe Warland
(FRSGlobal)
Sent: Wednesday, October 05, 2005 4:36 PM
To: [email protected]
Subject: Re: [JAWIN] Remolty access to the registry with WMI
How about using arrays? i.e. :
names = new Variant.ByrefHolder(new String[0]);
types = new Variant.ByrefHolder(new int[0]);
-----Original Message-----
From: Discussion of Java/Win32/COM integration with Jawin
[mailto:[email protected]] On Behalf Of Eric Baelen
Sent: Wednesday, October 05, 2005 4:31 PM
To: [email protected]
Subject: Re: Remolty access to the registry with WMI
I progress in my investigation.
I call the method EnumValues on the StdRegProv object.
The method has the following signature:
uint32 EnumValues([IN] uint32 hDefKey = 2147483650, [IN] string
sSubKeyName, [out] string sNames[], [out] sint32 Types[])
I try to do something like that:
Variant.ByrefHolder names = new Variant.ByrefHolder(new String());
Variant.ByrefHolder types = new Variant.ByrefHolder(new Integer(0));
wbemObject.invokeN("EnumValues ", new Object[] {
RegistryConstants.HKEY_LOCAL_MACHINE,
"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall", names,
types});
but after names.getRef() is null
Any idea?
Tx
Eric
-----Original Message-----
From: Discussion of Java/Win32/COM integration with Jawin
[mailto:[email protected]] On Behalf Of Eric Baelen
Sent: Wednesday, October 05, 2005 9:22 AM
To: [email protected]
Subject: [JAWIN] Remolty access to the registry with WMI
Hi,
I try to access remotely the registry with WMI:
ISWbemLocator wbemLocator = new
ISWbemLocator("WbemScripting.SWbemLocator");
ISWbemServices wbemServices = wbemLocator.ConnectServer("10.7.1.22",
"root/default", "user", "password", "", "", 0, null);
ISWbemObject wbemObject = wbemServices.Get("StdRegProv", 0,
null);
System.out.println(wbemObject.GetObjectText_(0).toString());
The System.out.println displays the StdRegProv class definition:
[Locale(1033), dynamic: ToInstance, provider("RegProv")]
class StdRegProv
{
[implemented, static] uint32 CreateKey([IN] uint32 hDefKey =
2147483650, [IN] string sSubKeyName);
[implemented, static] uint32 DeleteKey([IN] uint32 hDefKey =
2147483650, [IN] string sSubKeyName);
..
}
As my knowledge of COM is very limited, I'm basically stuck here. In
VBscript samples, it seems very easy:
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
Set objService = objLocator.ConnectServer( strComputer, "Root\Default",
strUserName, strPassword )
Set objRegistry = objService.Get( "StdRegProv" )
objRegistry.DeleteKey(HKEY_LOCAL_MACHINE,
"SYSTEM\CurrentControlSet\Services\admin51-serv")
Has someone already done this? How can I call EnumValues on my object
wbemObject ?
Thanks for you help
Eric