How do you read and Write to the reg in C#?
-Lou 3 2295
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)
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
"LOCALMACHI NE", if you want to change it to another HKEY, then just do a
"Find" on "LocalMachi ne" 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.LocalM achine.CreateSu bKey( szSubKey );
reg.SetValue( szName, szData );
}
public static string GetValue ( string szSubKey, string szName )
{
RegistryKey reg;
reg = Registry.LocalM achine.OpenSubK ey ( szSubKey );
if ( reg != null )
return Convert.ToStrin g(reg.GetValue( szName ));
else
return null;
}
public static string[] GetSubKeys ( string szSubKey )
{
RegistryKey reg;
reg = Registry.LocalM achine.OpenSubK ey( szSubKey );
if ( reg != null )
return reg.GetSubKeyNa mes();
else
return null;
}
}
}
if you've got any questions let me know.
Dan.
"Lou" <lo********@com cast.net> wrote in message
news:ec******** ******@TK2MSFTN GP09.phx.gbl...
How do you read and Write to the reg in C#?
-Lou
Thanks Dan.... Very helpfull
"Daniel Bass" <I'm really @ sick of spam> wrote in message
news:%2******** *******@tk2msft ngp13.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 "LOCALMACHI NE", if you want to change it to another HKEY, then just do a "Find" on "LocalMachi ne" 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.LocalM achine.CreateSu bKey( szSubKey ); reg.SetValue( szName, szData ); }
public static string GetValue ( string szSubKey, string
szName ) { RegistryKey reg; reg = Registry.LocalM achine.OpenSubK ey ( szSubKey ); if ( reg != null ) return Convert.ToStrin g(reg.GetValue( szName )); else return null; }
public static string[] GetSubKeys ( string szSubKey ) { RegistryKey reg; reg = Registry.LocalM achine.OpenSubK ey( szSubKey ); if ( reg != null ) return reg.GetSubKeyNa mes(); else return null; } } }
if you've got any questions let me know. Dan.
"Lou" <lo********@com cast.net> wrote in message news:ec******** ******@TK2MSFTN GP09.phx.gbl... How do you read and Write to the reg in C#?
-Lou This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 at all. So, conceivably as
applications are migrated to .NET, the registry could
disappear in a future version of Windows. Does anybody
out there agree with me?
Of course, they might keep the registry for backward
compatibility purposes.
|
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 folders and
desktop.
I hope someone can help me to better understand what this log excerpt
means, or point me to info sources that do a good job of explaining how
to interpret exactly what the various phrases, words, and numbers in
the log mean.
|
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 count exceeded. Increase MaxLocksPerFile registry
entry."
I checked in the Tools - Options - Advance. I have the database shared
with no locks selected and record level locking selected.
|
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(""))
|
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...
| |
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 '/CinemaBookingSystem' Application.
--------------------------------------------------------------------------------
ERROR General error
Unable to open registry key 'Temporary (volatile) Jet DSN for process
|
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 program, so that the
program can check for that key to see if the product has been installed and
stop a second installation or illegal installation.
If not orphan, can you encrypt the Key so that only your program can decrypt
|
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.
Dim aKey As RegistryKey
aKey = Registry.CurrentUser.OpenSubKey("software\myApplication")
I then attempt to read in any existing values
|
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 object with 10 string items into the registry and
retreive them later. I tried this:
key.SetValue("lstNSXitems", lstNSX.Items)
where "lstNSXitems" is the name of the subkey, and lstNSX.Items is the
|
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...
|
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...
| |
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
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...
|
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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |