By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,534 Members | 950 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,534 IT Pros & Developers. It's quick & easy.

Registry Question

P: n/a
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
Nov 21 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a

"Joe Delphi" <de*******@nospam.earthlink.net> wrote in message
news:Ll*****************@newsread3.news.pas.earthl ink.net...
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
Nov 21 '05 #2

P: n/a
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)
Nov 21 '05 #3

P: n/a
Thanks, I do not know what the original question but this just saved me
a lot of trouble

Jack Russell
Crouchie1998 wrote:
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)


Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.