473,395 Members | 1,941 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Having trouble with stdregprov and uintvalue..

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 =---
Nov 20 '05 #1
2 1762
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
----------------
"Text" <ma*@mas.com> a écrit dans le message de
news:40**********@127.0.0.1...
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

=---
Nov 20 '05 #2
You need to just specify what type the literal is:
dim dword as uint32

dword = convert.ToInt32(&H80000000)

' does not work, you get the "Value was too large or too small..."
exception.
' probably because that literal resolves to be a negative number

dword = convert.ToInt32(&H80000000L)

' this one does work, the "L" casts it long and keeps it positive
And it avoids the parsing trick. :)

Now, if they would only give us a literal cast that would let us bypass
the convert part.

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Anand | last post by:
Hi i am having trouble adding a recordset into the access database, the code seems to be working fine it passs and parses through all variables just fine without showing any errors and also when i...
1
by: Text | last post by:
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...
1
by: ajackson | last post by:
i am having some trouble installing SQl server Reporting Services. well, in order to install the reporting services i have to install Service Pack 3a. so through my installation of package 3a i...
1
by: mr_burns | last post by:
hi there, Ive been having a few problems recently with this group. Im not sure if any of the other groups have been giving me trouble but recently this one has a couple of times, when attempting...
2
by: ed | last post by:
i'm having trouble with a form. I want to be able to type in the address of the form with the data for the form items in the URL (ie: http://somesite.com/formpage.html?field1=data1&field2=data2)....
1
by: Lauren Wilson | last post by:
I'm having trouble with the Access VBA help on my installation of A2K with Dev tools. Every time I try to retrieve help for items listed in the Object Browser (and SOME other items as well),...
2
by: Jozef | last post by:
Hello, I am trying to put together a module and open a workspace on a database that has a simple password (using Access XP). This is the lin that I'm having trouble with; Set wrk =...
0
by: scheru | last post by:
I am trying to access the stdregprov using the COM interface using C++. I am unsuccessful in invoking the Put method that initializes the variables before calling the Exec method of...
0
by: Jozef | last post by:
Hello, I'm having trouble with the download links on my web server. The error I'm getting is; CGI Timeout The specified CGI application exceeded the allowed time for processing. The server...
2
by: Stu | last post by:
Hi guys, I've been having trouble getting the clock function to work portably, please could I get some thoughts? <Possibly OT comments> It works fine on my laptop (under WinXP) and on my...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.