473,804 Members | 3,004 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_MA CHINE\Software\ Techtracker"
if(registryKey. Equals(Registry .Localmachine.C reateKey("Softw are").CreateKey ("Techtracker") .Name)

MessageBox.Show ("Registry Key Exists")

els

MessageBox.Show ("Registry Key doesn't Exists")
I also tried using registryKey.Equ als(Registry.Lo calmachine.Open Key("Software") .OpenKey("Techt racker").Name), but this gives me an error. Any ideas or feed on this will be greatly appreciated.
Nov 15 '05 #1
2 47187
Microsoft.Win32 .RegistryKey subKey =
Microsoft.Win32 .Registry.Local Machine.OpenSub Key(Software\\T echTracker);

If (subKey != null)

{

MessageBox.Show ("Registry Key exists");

}

else

{

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

}

Dale
"Ed P." <an*******@disc ussions.microso ft.com> wrote in message
news:0E******** *************** ***********@mic rosoft.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_MA CHINE\Software\ Techtracker";
if(registryKey. Equals(Registry .Localmachine.C reateKey("Softw are").CreateKey (
"Techtracker"). Name)) {
MessageBox.Show ("Registry Key Exists");
}
else
{
MessageBox.Show ("Registry Key doesn't Exists");
}

I also tried using

registryKey.Equ als(Registry.Lo calmachine.Open Key("Software") .OpenKey("Techt r
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
4526
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 "ENOENT", The file doesn't exist.
1
1218
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
1695
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 display links to documents that actually exist. And alternatively generate a list of invalid links. Problem is that a link to an invalid document in some cases redirects
1
2833
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 Dim returnValue As Boolean = LogonUser(m_ntid, m_domain, m_pwd, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, tokenHandle)
0
2839
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 calling the proc , if so i want to use the values in the temp table, else i will dummy them out in the proc.
0
24547
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
4304
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 the user only needs to choose a programme code to create a record. I have a button that alows the user to close the form. If a record already exsits obviously a new record isn't created but the user has no warning of this. So my question is...
4
2580
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 skip it. I thought I could check for the existence of an object by comparing to null. However, in the global.asax code below, the "if (Request == null)" line throws the error "Request is not available in this context".
0
1154
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 situations when I may extract up to 4 fields from the database but not all four may be populated. Is there any way with my ASP.net markup that I can check to see if the template field is not null before attempting to write out any markup.
2
9851
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 the document headers, not the data. request.Credentials = System.Net.CredentialCache.DefaultCredentials; // This may throw a WebException:
0
9706
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
9577
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
10075
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
9140
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...
1
7615
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6847
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();...
1
4295
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
2
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2990
bsmnconsultancy
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...

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.