AlexPonnath
asked on
How can i read and write to registry from VB.net
I am looking for some code which does the folowing
a) read a specified registry key
b) write a value to a specific key
c) check if a key exists
d) create a new key
a) read a specified registry key
b) write a value to a specific key
c) check if a key exists
d) create a new key
http://www.codeproject.com/vb/net/registry_with_vb.asp
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Ok something is missing here..
i am using the code from the link provided, except i placed it in a module when i try to compile i get an error for
C:\Documents and Settings\Administrator.ICC INET\My Documents\Visual Studio Projects\LIBD\customeLooku p.vb(62): 'LocalMachine' is not a member of 'LIBD.registry'.
any idea what i am missing ?
Imports Microsoft.Win32
Module registry
Public Function createKey()
Dim regKey As RegistryKey
regKey = registry.LocalMachine.Open SubKey("SO FTWARE", True)
regKey.CreateSubKey("MyApp ")
regKey.Close()
MsgBox("Registry key HKLM\Software\MyApp created.")
End Function
i am using the code from the link provided, except i placed it in a module when i try to compile i get an error for
C:\Documents and Settings\Administrator.ICC
any idea what i am missing ?
Imports Microsoft.Win32
Module registry
Public Function createKey()
Dim regKey As RegistryKey
regKey = registry.LocalMachine.Open
regKey.CreateSubKey("MyApp
regKey.Close()
MsgBox("Registry key HKLM\Software\MyApp created.")
End Function
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Do you have the rights to access the registry ?
Does you subKey exist ?
Does you subKey exist ?
That seems overly complicated, here is how I do it:
SaveSetting("APPLICATION_N AME", "FOLDER_NAME", "File_Name", "VALUE_YOU_WANT_STORED")
GetSetting("APPLICATION_NA ME, "FOLDER_NAME", "File_Name", "")
DeleteSetting(APPLICATION_ NAME, "FOLDER_NAME")
These values will be stored in the registry under "My Computer\HKEY_CURRENT_USER \Software\ VB and VBA Program Settings"
SaveSetting("APPLICATION_N
GetSetting("APPLICATION_NA
DeleteSetting(APPLICATION_
These values will be stored in the registry under "My Computer\HKEY_CURRENT_USER
Well the code samples given have been to access anywhere in the registry... hence the "complication"
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.