C# Winform 注册程序开机启动

1 开机启动

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");

 

posted @ 2014-07-11 11:44  立己达人  阅读(324)  评论(0编辑  收藏  举报