Solved

Read/Write to registry in Binary (VB5)

Posted on 1998-06-15
6
413 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
[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
  • 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
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…

705 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