当前位置:编程学习 > C#/ASP.NET >>

急!!控制台程序设为开机启动程序不能正常运行

主程序如下
static void Main(string[] args)
        {
            _monitor.OnFileChanged += new Action<FileSystemEventArgs>(FileChanged);
            _aPDefault = (NameValueCollection)ConfigurationManager.GetSection("APDefault");

            Start();

            //SetAutoRun(Application.ExecutablePath, true);

            Console.Title = "监控界面";
            Console.WriteLine("监控人信息...");
            //隐藏窗体
            if (bool.Parse(GetKeyVaule("AutoHide")))
            {             
                IntPtr hCMD = Monitor.FindWindow(null, Console.Title);
                Monitor.ShowWindow(hCMD, 0);
            }
                        
        }
将此控制台程序设为开机启动后,本应自动隐藏窗口的却没自动隐藏,不知是什么原因(手工启动可以自动隐藏)
static void Main(string[] args)
        {
            _monitor.OnFileChanged += new Action<FileSystemEventArgs>(FileChanged);
            _aPDefault = (NameValueCollection)ConfigurationManager.GetSection("APDefault");

            Start();

            //SetAutoRun(Application.ExecutablePath, true);

            Console.Title = "监控界面";
            Console.WriteLine("监控人信息...");
            //隐藏窗体
            if (bool.Parse(GetKeyVaule("AutoHide")))
            {             
                IntPtr hCMD = Monitor.FindWindow(null, Console.Title);
                Monitor.ShowWindow(hCMD, 0);
            }
            //设置随机启动
            SetAutoRun(Application.ExecutablePath, true);
            
        }
如果写入注册表表,可以开机启动并自动隐藏,但程序不能正常运行 --------------------编程问答-------------------- 关注...... --------------------编程问答-------------------- static void Main(string[] args)
  {
  _monitor.OnFileChanged += new Action<FileSystemEventArgs>(FileChanged);
  _aPDefault = (NameValueCollection)ConfigurationManager.GetSection("APDefault");

  Start();

  //SetAutoRun(Application.ExecutablePath, true);

  Console.Title = "监控界面";
  Console.WriteLine("监控人信息...");
  //隐藏窗体
  if (bool.Parse(GetKeyVaule("AutoHide")))
  {   
  IntPtr hCMD = Monitor.FindWindow(null, Console.Title);
  Monitor.ShowWindow(hCMD, 0);
  }
  //设置随机启动
  SetAutoRun(Application.ExecutablePath, true);
    
  }
如果写入注册表表,可以开机启动并自动隐藏,但程序不能正常运行,提示一个.DAT文件不存在,实际是存在的;若通过双击运行程序则不会出问题;请高手赐教了。。。谢谢了。。。 --------------------编程问答-------------------- 我也遇到这个问题了,双击启动没问题,但是开始自动启动就不能正常使用,我的是winform应用程序 --------------------编程问答-------------------- 什么系统?设置成在启动的哪个部分运行的?
补充:.NET技术 ,  C#
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,