Solved

Read/Write to registry in Binary (VB5)

Posted on 1998-06-15
6
402 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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…

747 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now