473,396 Members | 1,722 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,396 software developers and data experts.

How to check that registry key exists

hello, I want to check to see if a certain registry key exists on the registry. What's the easiest way to do this. Here is what I am currently doing.
private string registryKey = @"HKEY_LOCAL_MACHINE\Software\Techtracker"
if(registryKey.Equals(Registry.Localmachine.Create Key("Software").CreateKey("Techtracker").Name)

MessageBox.Show("Registry Key Exists")

els

MessageBox.Show("Registry Key doesn't Exists")
I also tried using registryKey.Equals(Registry.Localmachine.OpenKey(" Software").OpenKey("Techtracker").Name), but this gives me an error. Any ideas or feed on this will be greatly appreciated.
Nov 15 '05 #1
2 47009
Microsoft.Win32.RegistryKey subKey =
Microsoft.Win32.Registry.LocalMachine.OpenSubKey(S oftware\\TechTracker);

If (subKey != null)

{

MessageBox.Show("Registry Key exists");

}

else

{

MessageBox.Show("Registry Key does not exist");

}

Dale
"Ed P." <an*******@discussions.microsoft.com> wrote in message
news:0E**********************************@microsof t.com...
hello, I want to check to see if a certain registry key exists on the registry. What's the easiest way to do this. Here is what I am currently
doing. private string registryKey = @"HKEY_LOCAL_MACHINE\Software\Techtracker";
if(registryKey.Equals(Registry.Localmachine.Create Key("Software").CreateKey(
"Techtracker").Name)) {
MessageBox.Show("Registry Key Exists");
}
else
{
MessageBox.Show("Registry Key doesn't Exists");
}

I also tried using

registryKey.Equals(Registry.Localmachine.OpenKey(" Software").OpenKey("Techtr
acker").Name), but this gives me an error. Any ideas or feed on this will
be greatly appreciated.
Nov 15 '05 #2
Thanks dale, this seems to do the trick for what I was looking for!
Nov 15 '05 #3

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

Similar topics

10
by: Raymond | last post by:
Hi All: To find a file exists using the file name, I have tow routings on UNIX system. 1. access(2) 2. lstat(2) This tow function also can do. When the return value is "-1" and errno is...
1
by: | last post by:
Hello, I need to add an entry to the system registry using C#. Can I do it using a normal filewriter objects or do I need to take any extra precautions. TIA!
1
by: Pete | last post by:
Hi, i'm building a datagrid that grabs a documents location out of a database and puts them in as a hyper link column. Ideally i'd love to be able to check the validity of the link and only...
1
by: James | last post by:
vb.net 2003 i wrote a windows service that does threading. My codes are a) the service thread will read a list of machine from a text file (machines.txt). b) it then logon using the below...
0
by: Herb | last post by:
is there a way in an SQL stored proc to determine if a temp table exists before selecting from it....I have a java app. that is calling a stored proc. i want to check if Java created the table before...
0
by: ramith | last post by:
Guys, I wrote a simple code to check the existence of a directory (in UNIX based file systems) which is working for me. Have I done it in the correct way? #include <dirent.h>
9
reginaldmerritt
by: reginaldmerritt | last post by:
I have a table which uses two primary keys. One is a canidate code the other is a course\programme code. I have a fom with these two fields but automaticaly picks the candidates code. Therefore...
4
by: Mark Berry | last post by:
Hi, I'm working on my "last resort" error block for a web application. If the error occurs after a Request has been made, I want to show the URL. If the Request object is not available, I'll...
0
by: philip.poole | last post by:
Hi everyone, I am settings up some .NET controls on my website and want to create template controls to completely separate the business layer and the presentation layer. However I have...
2
Manikgisl
by: Manikgisl | last post by:
HI. How to check File exists in Web Share C# try { WebRequest request = HttpWebRequest.Create("http://www.microsoft.com/NonExistantFile.aspx"); request.Method = "HEAD"; // Just get...
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...
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
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...
0
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
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...
0
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
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...

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.