473,549 Members | 2,741 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Test for Registry Key/Value

How do you test to see if a Registry Key & a Value exsist?
Nov 16 '05 #1
2 8042
Yogi_Bear_79,

You can use the RegistryKey class in the Microsoft.Win32 namespace. You
can call the GetValue method, which will return null if the value doesn't
exist. To check to see if a key exists, you can call the OpenSubKey method,
which will also return null if it doesn't exist.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Yogi_Bear_ 79" <IT*****@spamfr ee.com> wrote in message
news:iL******** ************@co mcast.com...
How do you test to see if a Registry Key & a Value exsist?

Nov 16 '05 #2
I've been trying variations on that concept before and after my original
question with no luck. Can you give me a quick "aircode" example?

using (RegistryKey Key = Registry.Curren tUser)

{

if (Key.OpenSubKey (sKey)= null)

{

}

}

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:ek******** ******@TK2MSFTN GP11.phx.gbl...
Yogi_Bear_79,

You can use the RegistryKey class in the Microsoft.Win32 namespace. You can call the GetValue method, which will return null if the value doesn't
exist. To check to see if a key exists, you can call the OpenSubKey method, which will also return null if it doesn't exist.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Yogi_Bear_ 79" <IT*****@spamfr ee.com> wrote in message
news:iL******** ************@co mcast.com...
How do you test to see if a Registry Key & a Value exsist?


Nov 16 '05 #3

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

Similar topics

9
15835
by: Michael A. Covington | last post by:
What is the best way to test whether .NET 1.1 is installed on someone's machine? I'd like to give him a small program to run to test this, and based on the answer, he'll download either the big version (with dotnetfx.exe) or the small version of the install package for the app we're distributing. Test for existence of a directory under...
1
16301
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...
5
1489
by: Yogi_Bear_79 | last post by:
I've been playing with the RegistryKey class in the Microsoft.Win32 namespace. I can do various things but I can't seem to get the syntax correct to see if a value or a key exsists. I know I need to use the GetValue & OpenSubKey methods I've been trying variations on these methods with no luck. Can someone give me a working example?
1
2562
by: Adnan Selimovic | last post by:
Hi folks! I have Framework 1.0 installed and I would like to point to registry from my Web.config file: <connectionString> <add key="password" value="registry:HKLM\Software\Foo,password" /> <add key="userID" value="registry:HKLM\Software\Foo,userID" /> <add key="initialCatalog" value="registry:HKLM\Software\Foo,initialCatalog" /> <add...
6
16795
by: CMG | last post by:
I am writing a little code to associate an extention with my program. And as far as i can see, i need to do the following: Public Function associatefile(ByVal FILE_EXTENTION_TO_ASSOCIATE As String, ByVal FILE_EXTENTION_DESCRIPTION As String, ByVal EXE_NAME As String, ByVal DEFAULT_OPEN_COMMAND As String, ByVal DEFAULT_ICON As String, ByVal...
4
9085
by: Kevin L | last post by:
I store some application settings in the registry under HKEY_LOCAL_MACHINE\Software\MyApplication I want to allow full access to this key and subkeys. Currently, I manually change the permissions on the keys. How can I accomplish this through code?
2
5566
by: Ben | last post by:
I think I might have found a bug in Visual Studio. The following code should work and doesn't: My.Computer.Registry.LocalMachine.CreateSubKey("Software\Dravet") My.Computer.Registry.LocalMachine.SetValue("HKEY_LOCAL_MACHINE\Software\Dravet", "loglevel", "1") My.Computer.Registry.LocalMachine.GetValue("loglevel") This code does work:...
3
1788
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
6
2519
by: ewolfman | last post by:
Hi, Is there any way in which I can monitor / hook the Registry, and upon a call to a specific key from a specific application - swap the returned value? I was thinking of using this method to overcome the "click" sound of the WebBrowser, without having to affect the Registry permanently. This way I could monitor the call for the sound...
0
7520
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...
0
7450
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...
0
7720
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. ...
0
6043
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...
1
5368
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5088
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...
0
3500
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...
0
3481
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1941
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.