• .Net 程序加入到开机启动项(备忘)


    如何把.Net 程序加入到开机启动项中

    private void RegCompStartRun(bool cmd)
     {
                //获取程序执行路径..
                string starupPath = Application.ExecutablePath;
           //表示Window注册表中项级节点,读取 Windows 注册表基项HKEY_LOCAL_MACHINE           
                RegistryKey loca = Registry.LocalMachine;
                RegistryKey run = loca.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");
                lblDisplay.Text += "执行成功!";
                try
                {
                   //SetValue:存储值的名称
                if (cmd)
                    {
                        run.SetValue("WinForm", starupPath);//加入注册,参数一为注册节点名称(随意)
                }
                    else
                    {
                        run.DeleteValue("WinForm",false);//删除该注册节点
                }
                    loca.Close();
                }
                catch(Exception ee)
                {
                    MessageBox.Show(ee.Message.ToString(),"提示",MessageBoxButtons.OK,MessageBoxIcon.Error);
                }
    
     }
    

    有了这个就可以使Winform程序开机自动运行。
  • 相关阅读:
    大四实习有点晚[转载]
    .net2.0数据绑定语法
    明天要去南京了
    Master & Content Page Relation(Event Ordering)
    在验证中使用图像和声音(ErrorMessage)
    设置FLash透明
    Basic Skill in .net2.0
    教育研究方法
    程序员是如何捕猎大象的[转]
    My lost card
  • 原文地址:https://www.cnblogs.com/NatureSex/p/2014088.html
Copyright © 2020-2023  润新知