Solved

Read/Write to registry in Binary (VB5)

Posted on 1998-06-15
6
411 Views
Last Modified: 2008-03-04
I need to be able to read and write to registry in Binary with VB5.  I know how to do Strings, Integers, Logicals, ect.
0
Comment
Question by:Chizl
  • 3
  • 2
6 Comments
 
LVL 1

Expert Comment

by:tstrob
ID: 1463335
Use API

RegOpenKeyEx to open the Registry
RegQueryValueEx to read the Value
RegCloseKey

RetVal = REgOpenKey(HKEY_LOCAL_MACHINE,"SOFTWARE\....",0,KEY_QUERY_VALUE, hkey);
RetVal = ReqQueryValueEx(hkey, "SourcePath",0, REG_SZ, ByVal Value, Len(Value))
RetVal = RegCloseKey(hkey)

msgbox "Your RegistryValue is : "  & value

All defined in API-Viewer:
HKEY_LOCALMACHINE
REG_SZ -> String (Null-Terminated)
REG_BINARY -> Number
REG_DWORD -> Double
KEY_QUERY_VALUE

hkey  is a long, it is a handle to your registry-key

For more details just ask...


0
 
LVL 4

Author Comment

by:Chizl
ID: 1463336
I tested this and get back garbage.  Again I need to write this as well.  I relize it is binary, but I need to retrive this info and use it to place in other registries.  For instance the program we are writing will need the registry entries of:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\OLE, "DefaultAccessPermission" which is binary.   I need to be able to store that and then write it to a different registy on a different computer.
0
 
LVL 4

Author Comment

by:Chizl
ID: 1463337
I tested this and get back garbage.  Again I need to write this as well.  I relize it is binary, but I need to retrive this info and use it to place in other registries.  For instance the program we are writing will need the registry entries of:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\OLE, "DefaultAccessPermission" which is binary.   I need to be able to store that and then write it to a different registy on a different computer.
0
Independent Software Vendors: 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 4

Author Comment

by:Chizl
ID: 1463338
Well that will not work.
0
 

Expert Comment

by:TpB
ID: 1463339
Nothing prevents you from writing any value you want, write and read it, and interpit it however.

' Place some settings in the registry.
SaveSetting appname := "MyApp", section := "Startup", _
            key := "Top", setting := 75
SaveSetting "MyApp","Startup", "Left", 50


GetSetting(appname := "MyApp", section := "Startup", _
                       key := "Left", default := "25")


0
 
LVL 1

Accepted Solution

by:
tstrob earned 100 total points
ID: 1463340
ok, I forgot to explain:
The variable to read the value in must be initialised before !
Value = Space(20)   'Strings
Value = 0                ' Binary, Long etc...
Then my code works !

To store in Registry use:
RegSetValueEx

(HKEY_LOCAL_MACHINE must not be part of the string containing the pathname)

Regards,
   tstrob
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
MS Date Picker 64 bit 32 bit issue 12 65
Help me. 3 71
Create Files based on Cell Values in a Range in Excel 12 43
VBA: Insert New column with specific format type 12 55
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

726 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