473,486 Members | 2,104 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Registry

Lou
How do you read and Write to the reg in C#?

-Lou
Nov 15 '05 #1
3 2281
Lou wrote:
How do you read and Write to the reg in C#?


Check out the Microsoft.Win32.Registry class.

--
There are 10 kinds of people. Those who understand binary and those who
don't.

http://code.acadx.com
(Pull the pin to reply)
Nov 15 '05 #2
i wrote a little wrapper that was handy for my use of the registry, maybe
it'll give you an idea as to how to get around. It's working with the HKEY
"LOCALMACHINE", if you want to change it to another HKEY, then just do a
"Find" on "LocalMachine" and change it to whatever other HKEY you want to
access...

using System;
using Microsoft.Win32; // where the reg stuff resides

namespace RegistryStuff
{
public class RegAnalyser
{
public static void SetValue ( string szSubKey, string szName,
string szData )
{
RegistryKey reg;
reg = Registry.LocalMachine.CreateSubKey( szSubKey );
reg.SetValue( szName, szData );
}

public static string GetValue ( string szSubKey, string szName )
{
RegistryKey reg;
reg = Registry.LocalMachine.OpenSubKey ( szSubKey );
if ( reg != null )
return Convert.ToString(reg.GetValue( szName ));
else
return null;
}

public static string[] GetSubKeys ( string szSubKey )
{
RegistryKey reg;
reg = Registry.LocalMachine.OpenSubKey( szSubKey );
if ( reg != null )
return reg.GetSubKeyNames();
else
return null;
}
}
}

if you've got any questions let me know.
Dan.
"Lou" <lo********@comcast.net> wrote in message
news:ec**************@TK2MSFTNGP09.phx.gbl...
How do you read and Write to the reg in C#?

-Lou

Nov 15 '05 #3
Lou
Thanks Dan.... Very helpfull

"Daniel Bass" <I'm really @ sick of spam> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
i wrote a little wrapper that was handy for my use of the registry, maybe
it'll give you an idea as to how to get around. It's working with the HKEY
"LOCALMACHINE", if you want to change it to another HKEY, then just do a
"Find" on "LocalMachine" and change it to whatever other HKEY you want to
access...

using System;
using Microsoft.Win32; // where the reg stuff resides

namespace RegistryStuff
{
public class RegAnalyser
{
public static void SetValue ( string szSubKey, string szName,
string szData )
{
RegistryKey reg;
reg = Registry.LocalMachine.CreateSubKey( szSubKey );
reg.SetValue( szName, szData );
}

public static string GetValue ( string szSubKey, string szName ) {
RegistryKey reg;
reg = Registry.LocalMachine.OpenSubKey ( szSubKey );
if ( reg != null )
return Convert.ToString(reg.GetValue( szName ));
else
return null;
}

public static string[] GetSubKeys ( string szSubKey )
{
RegistryKey reg;
reg = Registry.LocalMachine.OpenSubKey( szSubKey );
if ( reg != null )
return reg.GetSubKeyNames();
else
return null;
}
}
}

if you've got any questions let me know.
Dan.
"Lou" <lo********@comcast.net> wrote in message
news:ec**************@TK2MSFTNGP09.phx.gbl...
How do you read and Write to the reg in C#?

-Lou

Nov 15 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2604
by: Rohit Santhanam | last post by:
As I am reading the .NET documentation, I get the feeling that Microsoft is trying to get rid of the registry. My understanding is that an application built using .NET does not use the registry...
0
354
by: vincemoon | last post by:
Below is an excerpt from my Registry Log, created by Redmon, showing the process whereby TweakUI added the compressed folder option to the new sub-menu in the right click context menu for open...
1
16289
by: rdavis7408 | last post by:
I have a database that has a form that opens a report using date parameters. I have been using it for six months and last week I began to get the following Error Message: "File sharing lock...
8
5462
by: Al Kaufman | last post by:
I have a simple console app that uses: regSubKey = <some registry key> Dim reg As RegistryKey = Registry.ClassesRoot.OpenSubKey(regSubKey) Dim path As String path = CStr(reg.GetValue(""))
4
1365
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....
0
11998
by: bazzer | last post by:
hey, im trying to access a microsoft access database from an ASP.NET web application in visual basic 2003.NET. i get the following error when i try running it: Server Error in...
3
2059
by: eSolTec, Inc. 501(c)(3) | last post by:
Thank you in advance for any and all assistance. Is there a way to create a registry key, but orphan it from the program that created it? Reason: Create a key, but not associate it with the...
3
1783
by: Aussie Rules | last post by:
Hi, I want to store some data in the registry, however I have not been able to do this, and think my logic maybe flawed. Firstly I try to open the registry and read in any existing values....
6
1664
by: JOSII | last post by:
Getting a string of boolean value into and out of the registry is no problem. Here's the problem: Although you can place an object into the registry and retreive it, I need to place an ArrayList...
0
7100
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
7126
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,...
0
7175
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...
1
6842
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...
0
7330
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...
1
4865
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4559
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...
0
3070
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...
0
3070
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.