Saving to registry..........
I need to save some very simple things in my program to the registry. Can someone post a short example of how to Read and write to the windows registry? Also, are there any differences with this in Windows XP? All I need to save is whether or not a a checkbox is checked or not. Then when I load the program get the registery setting and set the checkbox value to that. To be honest, I don't need to save settings much in the small apps I make, and I have forgotten how to do this!:) I had a module of how to use Get & Save setting in one of my programs, but it was lost when I cleaned up my system and upgraded to Win XP. Any example appreciated.
Re: Saving to registry..........
Hack could u tell me if i can use your code to put read/write option to my vb6 application. could u explain to me where i can get the module for it. Api viewer dowload section has many thigns to downlod . which one do i need? thanks
Re: Saving to registry..........
without API:
VB Code:
'save to registry
'chkAutoCapsLock is a checkbox and im saving its value in the reg
'u can put this in a command button click event
SaveSetting "mySchool", "Settings", "AutoCaps", chkAutoCapsLock
to get the value and assign to checkbox:
VB Code:
Sub GetSettings()
On Error GoTo HELL
chkAutoCapsLock = CInt(GetSetting("mySchool", "Settings", "AutoCaps", "0"))
GoTo CleanUp
HELL:
WriteError Err.Number, Err.Description, Date, Me.Name, "GetSettings"
CleanUp:
End Sub
form the MSDN:
Quote:
GetSetting Function
Returns a key setting value from an application's entry in the Windowsregistry.
Syntax
GetSetting(appname, section, key[, default])
The GetSetting function syntax has thesenamed arguments:
Part Description
appname Required.String expression containing the name of the application or project whose key setting is requested.
section Required. String expression containing the name of the section where the key setting is found.
key Required. String expression containing the name of the key setting to return.
default Optional.Expression containing the value to return if no value is set in the key setting. If omitted, default is assumed to be a zero-length string ("").
Remarks
If any of the items named in the GetSetting arguments do not exist, GetSetting returns the value of default.
SaveSetting Statement
Saves or creates an application entry in the application's entry in the Windowsregistry.
Syntax
SaveSetting appname, section, key, setting
The SaveSetting statement syntax has thesenamed arguments:
Part Description
appname Required.String expression containing the name of the application orproject to which the setting applies.
section Required. String expression containing the name of the section where the key setting is being saved.
key Required. String expression containing the name of the key setting being saved.
setting Required.Expression containing the value that key is being set to.
Remarks
An error occurs if the key setting can’t be saved for any reason.