winform程序中  如何添加代码,让软件在开机后自启动???

解决方案 »

  1.   

    RegistryKey key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);//打开注册表子项  
    key.SetValue(程序的名称, 程序的路径);

    WshShell shell = new WshShell();   
    IWshShortcut shortcut = (IWshShortcut)shell.CreateShortcut(shortcutPath);   
      

  2.   

    修改注册表
    添加Windows计划任务
      

  3.   

    这个跟什么语言没有关系,Windows中什么语言写的基本都是操作注册表,可以向的五个自启动位置的任意一个添加值
    或者是设置系统服务,自启动
      

  4.   

    开机自动启动程序的函数:public void SetAutoRun(string fileName, bool isAutoRun)  
    {  
        RegistryKey reg = null;  
        try  
        {  
            if (!System.IO.File.Exists(fileName))  
                throw new Exception("该文件不存在!");  
            String name = fileName.Substring(fileName.LastIndexOf(@"\") + 1);  
            reg = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);  
            if (reg == null)  
                reg = Registry.LocalMachine.CreateSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run");  
            if (isAutoRun)  
                reg.SetValue(name, fileName);  
            else  
                reg.SetValue(name, false);  
            lbl_autorunerr.Visible = false;  
        }  
        catch  
        {  
            lbl_autorunerr.Visible = true;  
            //throw new Exception(ex.ToString());  
        }  
        finally  
        {  
            if (reg != null)  
                reg.Close();  
        }  
    }  
     使用的时候,直接调用SetAutoRun函数即可,这里解释一下两个参数的含义:fileName:需要设置自动启动程序的路径,若为当前程序可直接传递Application.ExecutablePath。isAutoRun:是否自动运行,为false时,取消自动运行。例:  SetAutoRun(Application.ExecutablePath, true);  //设置自动启动当前程序      SetAutoRun(Application.ExecutablePath, false);  //取消自动启动
      

  5.   

    方法有很多 如果楼主的程序是正当的(你懂我的意思)可以这样:
    复制程序-》粘贴程序到“C:\Documents and Settings\Administrator\「开始」菜单\程序\启动”目录下-》搞定
    恩 具体编程嘛 就是比如c#:
    API 中的CopyFile函数搞定。
    取消自启动嘛更简单 删掉OK.
      

  6.   


    开机自动启动程序的函数:public void SetAutoRun(string fileName, bool isAutoRun) 

    RegistryKey reg = null; 
    try 

    if (!System.IO.File.Exists(fileName)) 
    throw new Exception("该文件不存在!")……
      

  7.   

    nform程序中 如何添加代码,让软件在开机后自启动???
      

  8.   

    http://baidu.com