Registry Question

  • Thread starter Thread starter Joe Delphi
  • Start date Start date
J

Joe Delphi

Hi,

I want to store non-string values in the registry. I have a few
Boolean flags and some integer numbers that I want to store.

It appears that the SaveSettings command only handles the saving of
string values to the registry. Is there some other command that I should
use to save Boolean or Integer values to the registry?


JD
 
Joe Delphi said:
Hi,

I want to store non-string values in the registry. I have a few
Boolean flags and some integer numbers that I want to store.

It appears that the SaveSettings command only handles the saving of
string values to the registry. Is there some other command that I
should
use to save Boolean or Integer values to the registry?


JD

Use type casting such as blnFag.ToString, intNum.ToString,
Convert.ToBoolean(strFlag), Convert.ToInt32(strNum).

Dave
 
Start a new Windows application & add a button

Add the following import:

Imports Microsoft.win32

Double-click the button & add the following code:

Dim reg As RegistryKey
Dim intNumber As Integer = 1
Dim strKey As String = "Software\My Key"
reg = Registry.LocalMachine.CreateSubKey(strKey)
reg.SetValue("My Value", intNumber)
If Not reg Is Nothing Then reg.Close()

That will create a DWORD value

==============================

To create a string value:

Dim reg As RegistryKey
Dim strValue As String = "C:\My Directory"
Dim strKey As String = "Software\My Key"
reg = Registry.LocalMachine.CreateSubKey(strKey)
reg.SetValue("Startup Directory", strValue)
If Not reg Is Nothing Then reg.Close()

==============================

To create a boolean:

Dim reg As RegistryKey
Dim blnValue As Boolean = True
Dim strKey As String = "Software\My Key"
reg = Registry.LocalMachine.CreateSubKey(strKey)
reg.SetValue("My Boolean Value", blnValue)
If Not reg Is Nothing Then reg.Close()

I hope this helps

Crouchie1998
BA (HONS) MCP MCSE)
 
Thanks, I do not know what the original question but this just saved me
a lot of trouble

Jack Russell
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top