要用C#程序实现,谢谢各位指教!

解决方案 »

  1.   

    写一个windows服务,或者添加到启动组中
      

  2.   

    http://msdn.microsoft.com/library/chs/default.asp?url=/library/CHS/vbcon/html/vbwlkwalkthroughcreatingwindowsserviceapplication.asp
    这里是windows服务的写法。学习一下就搞定了。
      

  3.   

    把程序写进注册表的启动项:http://community.csdn.net/Expert/topic/5155/5155961.xml?temp=2.306765E-02
    服务也可以,但相比麻烦了点。
      

  4.   

    楼上说的是控制台应用程序,我要的是WINDOWS应用程序
      

  5.   

    楼上说的是控制台应用程序,我要的是WINDOWS应用程序
    ----------------------------------------------------
    一样的,试一下就知道了。
    如果是带Form的程序就不能用服务启动了,只能写进注册表。
      

  6.   

    学习中....
    我正要写一个这样的程序,不过我有一点不明白,为什么带Form的程序就不能用服务启动了,只能写进注册表?
      

  7.   

    我用两种方法实现:
    /// <summary>
    /// 作成者:jickie阿文  作成日時:2006/11/08 
    /// 処理内容:Applicationの自起動功能を追加します。
    /// </summary>
    private void SetRegistry()
    {
    try
    {

    string strAssName=Application.StartupPath+@"\"+Application.ProductName+@".exe";
    string ShortFileName=Application.ProductName;
    //
    RegistryKey rgkRun=Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",true);
    if(rgkRun==null)
    {//
    rgkRun=Registry.LocalMachine.CreateSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run");
    }
    else
    {
    rgkRun.SetValue(ShortFileName,strAssName);
    }
    }
    catch{}
    }
    /// <summary>
    /// 作成者:jickie阿文  作成日時:2006/11/22 
    /// 処理内容:Applicationの自起動功能を追加します。
    /// </summary>
    private void AddToStartUp()
    {
    try
    {
    DirectoryInfo dire=new DirectoryInfo(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Startup));

    if(File.Exists(dire.FullName+@"\"+Application.ProductName+@".lnk"))
    {
    File.Delete(dire.FullName+@"\"+Application.ProductName+@".lnk");
    }
    IWshRuntimeLibrary.WshShell shell = new IWshRuntimeLibrary.WshShell();
       IWshRuntimeLibrary.IWshShortcut shortcut = (IWshRuntimeLibrary.IWshShortcut)shell.CreateShortcut(dire.FullName+@"\"+Application.ProductName+@".lnk");
       shortcut.TargetPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
       shortcut.WorkingDirectory = System.Environment.CurrentDirectory;
       shortcut.WindowStyle = 7;
      shortcut.Description = this.Text;
       shortcut.Save();
    }
    catch{}
    }
      

  8.   

    其中IWshRuntimeLibrary是名字为Windows Script Host Object Model的COM参照
      

  9.   

    将要启动的应用写到currentuser下面的Software\Microsoft\Windows\CurrentVersion\Run
      

  10.   

    开机就自动启动程序一般分两种情况:
    1、将程序作成Windows服务,如果想减少人为的干扰,这种是比较好选择。只要你能写Windows服务程序,服务是自动或手动启动很简单的。
    2、如果是程序,修改注册表项也是比较好的,简单代码如下:
            private void button1_Click(object sender, EventArgs e)
            {
                string FullPathFile = Application.ExecutablePath;//获取带全路径的本程序
                Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true).SetValue("MyApp", FullPathFile);//将本程序加入到注册表的RUN中
                MessageBox.Show("已设定开机就要启动本程序。", "信息提示", MessageBoxButtons.OK);
            }        private void button2_Click(object sender, EventArgs e)
            {
                Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true).DeleteValue("MyApp", false);//将本程序从注册表的RUN中删除
                MessageBox.Show("已取消开机就启动本程序。", "信息提示", MessageBoxButtons.OK);
            }
      

  11.   

    服务 
    注册表 run 项 : 也可以写到 runonce 里 然后那个程序每次都写一次...
    .. 放到 ~\「开始」菜单\程序\启动 里
      

  12.   

    写一个windows服务,去启动你写的那个软件就ko了