读写注册表例程
private string GetValue()
{
Microsoft.Win32.RegistryKey subKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey
("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", false);
string str = subKey.GetValue("AnlogAutoStart").ToString();
Debug.WriteLine($"str = {str}");
return str;
}
private void AutoStartEXE()
{
Microsoft.Win32.RegistryKey registryKey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey
("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);
registryKey.SetValue("AnlogAutoStart", Application.ExecutablePath);//"AnlogAutoStart"自定义
}
上面的两个函数适当修改即可完成使用,增加相关参数即可用于参数保存
参考链接
特此记录
anlog
2023年2月24日