Home  |  Index  |  Dotnet4all Snippets  |  Submit resources
About  |  Mail us  
Dotnet4all Logo

  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

 
Previous Posts
    - Word library in server side?
    - vbFTPClient - kb article 812404
    - SqlCnx.Open() no error when MSSQLServer db engine ...
    - Putting code into GAC
    - Looking for Some Products
    - Implementing IComparable
    - Known Bug - Possible Workaround??
    - Graph in VB.Net
    - Having problems migrating an ASP .net Page to ano...
    - VB.NET 2003 Standard Classes & DLL Creation

Archives
    - 10/03/2004 - 10/10/2004
    - 10/10/2004 - 10/17/2004
    - 10/17/2004 - 10/24/2004
    - 10/24/2004 - 10/31/2004
    - 10/31/2004 - 11/07/2004
    - 11/21/2004 - 11/28/2004
    - 11/28/2004 - 12/05/2004
    - 12/05/2004 - 12/12/2004
    - 12/12/2004 - 12/19/2004
    - 12/19/2004 - 12/26/2004
    - 12/26/2004 - 01/02/2005
    - 01/23/2005 - 01/30/2005
    - 01/01/2006 - 01/08/2006
    - 09/24/2006 - 10/01/2006

Disclaimer & Terms of Use  | DotNet4All.Com concept & © 2004 - 2007 by  Zelders²  - Holland