Reading Windows Registry using C#

This C# code snippet reads a key from the Windows Registry.

Warning: Do not play with the Registry. If you do not know what you are doing, you can cause any number of costly problems. Use this code at your own risk.
using Microsoft.Win32;
...

RegistryKey masterKey = Registry.LocalMachine.CreateSubKey(
            "SOFTWARE\\Test\\Preferences");
if (masterKey == null)
{
    Console.WriteLine ("Null Masterkey!");
}
else
{
    Console.WriteLine ("MyKey = {0}", masterKey.GetValue ("MyKey"));
}
masterKey.Close();

That's It.
Advertisements

22 responses to this post.

  1. Hey there! I’m at work browsing your blog from my new apple iphone! Just wanted to say I love reading through your blog and look forward to all your posts! Keep up the outstanding work!

  2. I’ve been using the internet for the number of years now and never ever genuinely thought of testing the speed of our internet site, wonderful post i will check our web site speed now

  3. Locus is great just one, I like it much. Thx for the list.

  4. I’d personally move to Hawaii then travel the globe.

  5. We have tried almost everything I know to get the publish to go to “read more” it just brings me again for the same post no more text shows.

  6. Im having a teeny problem. I cant get my reader to pickup your rss feed, Im using yahoo reader by the way.

  7. This website has some really helpful stuff on it! Thank you for sharing it with me.

  8. Please message me with any hints & tips on how you made this site look like this , Id appreciate it.

  9. How come you do not have your site viewable in wap format? Can not view anything in my Droid.

  10. I Will have to visit again whenever my course load lets up – nevertheless I am getting your Rss feed so i could go through your blog offline. Cheers.

  11. Heya, I just hopped over to your site via StumbleUpon. Not somthing I might normally read, but I enjoyed your views none the less. Thanks for making some thing worthy of reading through.

  12. I tried taking a look at your blog with my mobile phone and the layout does not seem to be right. Might want to check it out on WAP as well as it seems most cellphone layouts are not working with your web site.

  13. How do you make your blog look this cool! Email me if you want and share your wisdom. Id appreciate it!

  14. Mate. This site is sick. How can I make it look like this !

  15. I tried taking a look at your blog on my blackberry and the design does not seem to be right. Might wanna check it out on WAP as well as it seems most cell phone layouts are not really working with your website.

  16. Can you email me with a few pointers about how you made your blog look this cool , I would be thankful!

  17. Strange , your post shows up with a black color to it, what shade is the primary color on your web site?

  18. Have you given any kind of consideration at all with translating your main web-site in to French? I know a couple of translaters here which might help you do it for free if you want to make contact with me.

  19. Make money on new film releases! Meet the James Bond of Social Networking. Would you like to be the first person out of the gate to make money on feature film releases? http://www.nutvnetwork.com/paybackjackaffiliate.html

  20. Wanted to drop a remark and let you know your Feed is not functioning today. I tried including it to my Google reader account but got nothing.

  21. Could you email me with some pointers about how you made your site look this cool , Id be appreciative.

  22. Do you have a spam problem on this internet site; I also am a blogger, and I was questioning your scenario; weve got made some great approaches and we are searching to swap options with other folks, be certain to shoot me an e-mail if serious.

Comments are closed.

%d bloggers like this: