Solved

Write Double Dword to registry?

Posted on 2001-08-20
6
871 Views
Last Modified: 2012-08-13
I need to write a double-long dword value to the registry from a VB app.  I am using a modregistry.bas file from the following link http://www.freevbcode.com/code/mkcRegistry.zip
which allows me to add normal long variables to the registry without any problem.  Unfortunately I have been unable to modify this module to add double-long integers.

Anyone know how to do this or know of any code that does this?
0
Comment
Question by:begreening
6 Comments
 
LVL 4

Expert Comment

by:aponcealbuerne
ID: 6408029
Hi
check for the RegSetValueEx function
Hope helps
0
 
LVL 3

Expert Comment

by:nzjonboy
ID: 6408094
this link gives a breakdown of the types you can have in the registry

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/sysinfo/hh/sysmgmt/regapi_41mb.asp

I am guessing you want to use a REG_QWORD (64 bit) value?

Open the module code and look for the declaration

Public Enum KeyType
  [REG_BINARY] = 3 'A non-text sequence of bytes
  [REG_DWORD] = 4 'A 32-bit integer...visual basic data type of Long
  [REG_SZ] = 1 'A string terminated by a null character
End Enum

This is where you should add the new type. Then just call, as you would normally, the read/write/delete/export functions with the new key type.

hope this helps

nzjonboy
0
 
LVL 1

Author Comment

by:begreening
ID: 6409892
Microsoft Media uses the following sentax for their registry entries.  

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\nsunicast\Parameters\Virtual Roots\/PubName]
"Path"="d:\\clients\\Company"
"MaxBandwidth"=dword:ffffffff
"MaxClients"=dword:ffffffff

If you open this key the value in hex is ffffffff.  When you switch to binary, the value is 4,294,967,295.  The code I have for adding values to the registry takes a string variable of the binary number and converts in to a long integer with the CLng function for it input into the RegSetValueEx function.  A long variable can only pass an integer as large as 2,147,483,648, which is exactly half of the number that Microsoft needs.  I tried replacing the CLng function with the CDbl function but this does not work, it puts zero values in the registry.
0
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
LVL 1

Author Comment

by:begreening
ID: 6409987
I guess another solution would be to output a text file (with .reg ext) with the registry entry like above and then merge it somehow.

Anyone have working code for either method?  
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6410765
I used last comment from you with success, but unfortunatelly, with strings only.
Anyway, i think that shouldn't be problems.
.....
"and then merge it somehow."

shell "regedit.exe /e /y " & "c:\myreg.reg",vnhide
0
 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 200 total points
ID: 6410824
Sorry...!!!

shell "regedit /s " & "c:\myfile.reg", vbhide
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question