Having trouble with stdregprov and uintvalue.
(Thursday, December 23, 2004)
Found the following interesting discussion in the Newsgroups:
Having trouble with stdregprov and uintvalue.. by:Text
| I'm trying to invoke the createkey method under StdRegProv but I can't seem to get the first imparam correct
it says that "Value was either too large or too small for a UInt32 when it processes current_user."
how do I pass a UInt32 value? Msdn has it listed as 0x80000001, but vb.net won't except that. hDefKey only accepts uint32 values... or so it seems. Const HKEY_current_user As Long = &H80000001
Dim strkeypath As Object = "Software\Microsoft\Internet Explorer\Main\mas"
Dim wmi As ManagementClass
Dim md As MethodData
Dim RemotePC As String
RemotePC = "."
wmi = New ManagementClass("\\" & RemotePC & "\root\default:StdRegProv")
Dim inParams As ManagementBaseObject = wmi.GetMethodParameters("Createkey")
inParams("hDefKey") = HKEY_current_user
inParams("sSubKeyName") = strkeypath
Dim outParams As ManagementBaseObject = wmi.InvokeMethod("Createkey", inParams, Nothing)
' Display results
' Note: The return code of the method is provided in the "returnValue" property of the outParams object
Console.WriteLine("Creation of registry returned: {0}", outParams("returnValue"))
----== Posted via Newsfeed.Com - Unlimited-Uncensored-Secure Usenet News==---- http://www.newsfeed.com The #1 Newsgroup Service in the World! >100,000 Newsgroups ---= 19 East/West-Coast Specialized Servers - Total Privacy via Encryption =---
| | | Reply: by:Olivier DALET
| | | Two answers: - first and best one (to me): use C# which provides unsigned types (uint, ulong, ...): const uint HKEY_current_user = 0x80000001;
- second one: using VB, I wrote this horrible (but working) piece of code: Const HKEY_current_user As String = "80000001" ... inParams("hDefKey") = UInt32.Parse(HKEY_current_user, System.Globalization.NumberStyles.HexNumber)
Maybe somebody will find a cleaner solution using VB ?...
Olivier DALET
|
|
0 Comments:
Post a Comment