Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Write Double Dword to registry?

Posted on 2001-08-20
6
Medium Priority
?
883 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 400 total points
ID: 6410824
Sorry...!!!

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses

715 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