C#.Net操作注冊表RegistryKey
1、加鍵加值
string appName = "PowerOffOnTime"; //獲取執行該方法的程序集,并獲取該程序集的文件路徑(由該文件路徑可以得到程序集所在的目錄) string thisExecutablePath = System.Reflection.Assembly.GetExecutingAssembly().Location; //SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run注冊表中這個路徑是開機自啟動的路徑 Microsoft.Win32.RegistryKey Rkey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"); Rkey.SetValue(appName, thisExecutablePath); Rkey.Close();
2、讀得鍵值
Microsoft.Win32.RegistryKey Rkey = Microsoft.Win32.Registry.LocalMachine.CreateSubKey ("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run"); string Key = Rkey.GetValue("PowerOffOnTime").ToString();
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!