|
-
Mar 4th, 2002, 09:15 AM
#1
Thread Starter
Lively Member
Reading & writing to the registry
How can I write and read from the registry?
-
Mar 4th, 2002, 09:17 AM
#2
-= B u g S l a y e r =-
u can use GetSetting and SaveSetting
sample
VB Code:
'// Make a new project. Add a module. To the form add three text boxes and two command buttons.
'// Code:
'// Add this code To the module:
Option Explicit
Public Const ThisApp = "My Company"
Public Const ThisKey = "My Prog Name"
Global Name As String
Global Phone As String
Global PostCode As String
'// Add this code To the first Command button:(Load)
Private Sub Command1_Click()
Dim Name, Phone, PostCode As String
Name = GetSetting(ThisApp, ThisKey, "Name", "")
Phone = GetSetting(ThisApp, ThisKey, "Phone", "")
PostCode = GetSetting(ThisApp, ThisKey, "PostCode", "")
Text1.Text = (Name)
Text2.Text = (Phone)
Text3.Text = (PostCode)
End Sub
'// Add this code To the Second Command button:(Save)
Private Sub Command2_Click()
Dim Name, Phone, PostCode As String
SaveSetting ThisApp, ThisKey, "Name", Text1.Text
SaveSetting ThisApp, ThisKey, "Phone", Text2.Text
SaveSetting ThisApp, ThisKey, "PostCode", Text3.Text
End Sub
-
Mar 4th, 2002, 09:28 AM
#3
Bouncy Member
note that if you want to be able to specify exactly where you want to put values in the registry and have more functionality with the registry you have to use the API registry funtions.
-
Mar 4th, 2002, 09:48 AM
#4
-= B u g S l a y e r =-
darre1 is right, this tutorial might help if u want to accomplish this : http://161.58.186.98/registry/registry2/
-
Mar 4th, 2002, 10:51 AM
#5
Fanatic Member
This works too.
Lots of people suggest useing API. I always suggest this
because its not alot of code.
Can anyone tell me whats better, this or API?
VB Code:
Private Sub Command1_Click()
Dim WshShell As Object
Set WshShell = CreateObject("wscript.Shell")
WshShell.RegWrite "HKLM\software\dumbtest\Value", "Update", "REG_SZ"
Debug.Print WshShell.RegRead("HKLM\software\dumbtest\Value")
WshShell.RegDelete "HKLM\software\dumbtest\Value" 'deletes value
WshShell.RegDelete "HKLM\software\dumbtest\Value\" 'deletes entire key
Set WshShell = Nothing
End Sub
That is all
Seahag
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|