C#操作windows注冊表的辦法。本站提示廣大學習愛好者:(C#操作windows注冊表的辦法)文章只能為提供參考,不一定能成為您想要的結果。以下是C#操作windows注冊表的辦法正文
本文實例講述了C#操作windows注冊表的辦法。分享給年夜家供年夜家參考。詳細以下:
此代碼演示了若何讀取和寫入注冊表
讀取注冊表:
private string GetRegistShellData(string RegistName) { try { string registData, SubregistData; RegistryKey hkml = Registry.LocalMachine; RegistryKey software = hkml.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon", true); registData = software.GetValue(RegistName).ToString(); SubregistData = registData.Substring(0, 2); return SubregistData; } catch (Exception excp) { MessageBox.Show("GetRegistShellData毛病" + excp.ToString(), "毛病", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return ""; }
寫入注冊表:
private void RenameRegistData() { try { string registData1; RegistryKey hkml = Registry.LocalMachine; RegistryKey software2 = hkml.OpenSubKey(@"SOFTWARE\"+ Shadowin + @"\SysToolSign", true); registData1 = software2.GetValue("Sign").ToString(); software2.SetValue("Sign", "1"); registData1 = software2.GetValue("Sign").ToString(); } catch (Exception excp) { MessageBox.Show("RenameRegistData毛病" + excp.ToString(), "毛病", MessageBoxButtons.OK, MessageBoxIcon.Warning); } return ; }
願望本文所述對年夜家的C#法式設計有所贊助。