473,804 Members | 2,164 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1315

"Joe Delphi" <de*******@nosp am.earthlink.ne t> wrote in message
news:Ll******** *********@newsr ead3.news.pas.e arthlink.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.ToBoole an(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\M y Key"
reg = Registry.LocalM achine.CreateSu bKey(strKey)
reg.SetValue("M y 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\M y Key"
reg = Registry.LocalM achine.CreateSu bKey(strKey)
reg.SetValue("S tartup 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\M y Key"
reg = Registry.LocalM achine.CreateSu bKey(strKey)
reg.SetValue("M y 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\M y Key"
reg = Registry.LocalM achine.CreateSu bKey(strKey)
reg.SetValue("M y 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\M y Key"
reg = Registry.LocalM achine.CreateSu bKey(strKey)
reg.SetValue("S tartup 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\M y Key"
reg = Registry.LocalM achine.CreateSu bKey(strKey)
reg.SetValue("M y 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
1923
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. I'm guessing that this can be done by accessing the registry, but some articles or sample code would be useful. Thanks.
3
3718
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 XML file instead of the registry. The other engineer argues that it is faster and easier to manipulate the registry than File I/O operations with the XML file. I just wanted ask you guys what are the strengths and weaknesses with
2
3230
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 save some power when CPU is idle (throttling). I need to do it in C, and the program need to be runnable in Linux. Anybody know the way, plz let me know. I really have no idea how to achieve this since I have no experience in registry programming....
8
10683
by: Saradhi | last post by:
Can any one put me a piece of code to write binary data into Registry?
2
1677
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... http://www.wwwcoder.com/main/parentid/263/site/2281/68/default.aspx what's the problem with a server side application reading data from a server
6
1030
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 stored value to print correct? and I want to treat the value as numeric thanks
4
1391
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. This seems much too large to be normal, even for a developer's machine. I've read in places that "it's not recommended that you register assemblies in the GAC when developing addins", yet the instructions for adding a path the IDE configuration...
9
4988
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 : database=northwind;user=username;password=pw; is stored at software/myApp/connSTR in the registry, i was told its possible to just place <connectionStrings> <add name="asd"
20
3807
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 that particular key. Example:
3
1648
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 "Local System." Thus, I can't rely on it always being ...\<Username>\Local Settings\Temp. So, this partially applies to C#, because I'll need to do this in C# code. But, I think I already know how to do it. What I don't know is where to find...
0
9714
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9594
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10600
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10351
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10096
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9174
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6866
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5534
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4311
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.