473,387 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Registry Question

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
3 1292

"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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: Swami | last post by:
I was wondering how I can programmatically find out the path of an installed program. I have an application that needs access to a config file that resides in the folder of another application. ...
3
by: Danny | last post by:
Hi I just have a quick question. One of our Windows based application uses the registry for configuration type options and some other things. I want to modify our application to move to use a...
2
by: Abby | last post by:
I'm sorry that I post this question in this newsgroup, but I don't know where is the right place to post. I have a question if I can get to CPU's registry to modify its clock cycle so that I can...
8
by: Saradhi | last post by:
Can any one put me a piece of code to write binary data into Registry?
2
by: Daniel Bass | last post by:
I've found this article on how to get ASP.Net to read/write from the server's registry, but it got heavily critted as being something that you should not do... ...
6
by: Gary | last post by:
Hi, I have a value stored in the registry "10." and when I extract the stored value and print it in a text form I only get a figure of "10" and not "10." why is this so? and how do I get my...
4
by: Bob | last post by:
My question about how to add an assembly search path to VS.NET's IDE remains unanswered, but I'm still faced with a problem possibly associated with this: my exported registry is more than 67MB....
9
by: nbs.tag | last post by:
hey guys heres my question. I was told by a little birdie that .net 2.0 has the ability to read a connection string directly from a registry key. so in the registry key a string value of say :...
20
by: Newbie Coder | last post by:
MFC Application VC++.NET 2003 I have a certain registry key (HKCU\Software\MyKey) that contains between 30 & 64 string values I need to write a '*' to all those 30 - 64 string values under...
3
by: thephatp | last post by:
BLUF: I need to build up the actual %TEMP% path for all users methodically using values in the registry, and I need to do this both by the current user AND as a service will do this running as...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.