Way to write on registry location

后端 未结 3 905
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-10 09:21

work on C# window application.I want to write on registry.i know how to write on registry.I use bellow syntax to write on registry.

        Microsoft.Win32.R         


        
3条回答
  •  粉色の甜心
    2020-12-10 09:39

    For HKCU:

    string keyName = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Run";
    RegistryKey rk = Registry.CurrentUser.OpenSubKey(keyName, true);
    rk.SetValue("abc", "efd");
    rk.Close();
    

    For HKLM you need to do it with administrative privileges. That requires adding a manifest to your program to invoke the UAC prompt on Vista or Win7.

提交回复
热议问题