Solved

Read/Write to registry in Binary (VB5)

Posted on 1998-06-15
6
403 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…

911 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

23 Experts available now in Live!

Get 1:1 Help Now