Link to home
Start Free TrialLog in
Avatar of Chizl
ChizlFlag for United States of America

asked on

Read/Write to registry in Binary (VB5)

I need to be able to read and write to registry in Binary with VB5.  I know how to do Strings, Integers, Logicals, ect.
Avatar of tstrob
tstrob

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...


Avatar of Chizl

ASKER

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.
Avatar of Chizl

ASKER

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.
Avatar of Chizl

ASKER

Well that will not work.
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")


ASKER CERTIFIED SOLUTION
Avatar of tstrob
tstrob

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial