Hi guys,
is their any api present to read and write to registry in VB, kindly provide me some sample
Printable View
Hi guys,
is their any api present to read and write to registry in VB, kindly provide me some sample
VB6 makes this simple to do, just useQuote:
Originally Posted by resumurof
SaveSetting
and
GetSetting
Note: All values are stored as strings
Example:
If you wanted to save a window's current width on unload so it could be used the next time the window was opened, you could save it's current width to the registry using the below code.
Where oForm is the form being closedCode:Dim sWidth as String
sWidth = CStr(oForm.width)
SaveSetting "MyAppName", "MyWindow", "Width", sWidth
Then to retrieve the value:
Code:Dim sDefaultValue as String
'sDefaultValue is used if registry value is not found
sDefaultValue = "600"
iWindowWidth = CInt(GetSetting("MyAppName", "MyWindow", "Width", sDefaultValue)
oForm.Width = iWindowWidth
Keep in mind that the getsetting and save setting functions write to the current user section of the registry under software.
This is the easiest way to write to the registry but there is also API calls that can be used which will allow you to write to other areas in the registry when needed.