c# winform如何实现开机自启动
发布网友
发布时间:2022-05-11 17:15
我来回答
共1个回答
热心网友
时间:2023-10-16 01:00
public static bool SetAutoRun(string keyName, string filePath)
{
try
{
RegistryKey Local= Registry.LocalMachine;
RegistryKey runKey =Local.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run\");
runKey.SetValue(keyName, filePath);
Local.Close();
} catch
{
return false;
}
return true;
}
SetAutoRun("exeName", Application.StartupPath + "\\step.exe");