将程序的启动路径写入到注册表的Run里面就能实现开机程序自动启动。
C#代码如下:
using Microsoft.Win32;
/// <summary>
/// 写入注册表开机启动/// </summary>
private void StartPCRun()
{
try
{
string FilePath =Application.ExecutablePath;
Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true).SetValue("OPRun", FilePath);
}
catch
{ }
}
1566

被折叠的 条评论
为什么被折叠?



