How to detect if a register string existed

  • Thread starter Thread starter ad
  • Start date Start date
ad said:
How can I detect if a register string existed with c#

What do you mean by a "register string"? Do you mean you want to search
through the Windows registry, looking for a key or value?

If so, the RegistryKey class is probably the best place to start.
 
Yes, I mean to test if a registry key exist in the Windows registry.
For example, I want to test if there exist the key
"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\IISADMIN"
How can I do that?
 
ad said:
Yes, I mean to test if a registry key exist in the Windows registry.
For example, I want to test if there exist the key
"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\IISADMIN"
How can I do that?

The easiest way is to use RegistryKey.OpenSubKey and see if it returns
null or not. (If it doesn't, remember to call Dispose on the returned
key.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top