Thursday, February 01, 2007

Read value from Registry

 

                Before few months when I was ne in Cygnet, I was assign a task to read store connection string in registry and read the value from there whenever require. This is something new and I had never implemented it before.

                  Thanks to my collegue (now friend ) SEHUL a little master, who helped me in doing this. Below is the code.

Microsoft.Win32.RegistryKey rgk = Microsoft.Win32.RegistryKey.OpenRemoteBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, "MachineName");

rgk = rgk.OpenSubKey(@"HARDWARE\DESCRIPTION\SYSTEM\CentralProcessor\0");
string strValue =Convert.ToString( rgk.GetValue("Identifier"));
MessageBox.Show(strValue);

Happy programming.

No comments: