Monday, March 30, 2015

How can I access the registry from C# code?

Question:How can I access the registry from C# code??

Answer: </P><P align=justify>By using the Registry and RegistryKey classes in Microsoft.Win32, you can easily access the registry. The following is a sample that reads a key and displays its value: using System;using Microsoft.Win32;</P><P align=justify>class regTest</P><P align=justify>{</P><P align=justify>public static void Main(String[] args)</P><P align=justify>{</P><P align=justify>RegistryKey regKey;</P><P align=justify>Object value;</P><P align=justify>regKey = Registry.LocalMachine;</P><P align=justify>regKey = </P><P align=justify>regKey.OpenSubKey("HARDWAREDESCRIPTIONSystemCentralProcessor�");</P><P align=justify>value = regKey.GetValue("VendorIdentifier");</P><P align=justify>Console.WriteLine("The central processor of this machine is: {0}.", value);</P><P align=justify>}</P><P align=justify>}

Tags:Interview Questions, Microsoft, C#,

Please submit your Interview Answer for the above Question via replying to this post. Thank you for visiting to our blog, Have a Good Day!.



Sponsor Advertisement



Bulk SMS Sending Software

SMS Management System Software

This software used to Send bulk SMS (short text messages) from your computer and assists you to rapidly connect with your customers and staff, communicate with them easily and cheaply, using latest technology that help to generate bulk SMS on just one click to all the database....

No comments:

Post a Comment