以下是源码,运行过后,点击command1,然后退出程序,重新调动系统,但是记事本还是没有打开,请问是什么原因?谢谢 public static bool SetAutoRun(string keyName, string filePath)
        {
            try
            {
                RegistryKey runKey = Registry.LocalMachine.OpenSubKey                         (@"\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true);
                runKey.SetValue(keyName, filePath);
                runKey.Close();
            }
            catch
            {
                return false;
            }
            return true;
        }        private void button1_Click(object sender, EventArgs e)
        {
            SetAutoRun("myexe", "d:\\notepad.exe");        }
    }

解决方案 »

  1.   

    notepad.exe在d盘下?不是吧,在system32下吧,所以怎么可能能打开呢?
      

  2.   

    我把notepad.exe放在d盘下面了,但是还是打不开
      

  3.   

    那你到注册表里查下,你加的键是否加进去了?我记得SetValue会返回值的,你看返回了没有,也就是成功了没有。
      

  4.   

    会不会和windows的环境变量有关?
      

  5.   

    RunWhenStart(true, "名称.exe", "C:\\Documents and Settings\\Administrator\\桌面\\名称.exe");后面写你想启动的路径