我写了一个服务程序,在系统启动时候自动启动
然后在某种情况下,希望由服务程序启动另外一个exe执行文件
我试了用
ShellExecute
WinExec
CreateProcess同样的语句,在普通程序里面可以启动另外一个程序(例如notepad.exe)
但是在服务程序里面就没有反应了请各位指教!

解决方案 »

  1.   

    If you run the service under any user account -
    it has absolutely NO ACCESS to the interactive deskrop! if you run the
    service under LocalSystem, you can check the option to allow it to
    interact with the desktop. 
      

  2.   

    谢谢各位 kingzai(感悟中) 能给个代码的例子吗
      

  3.   

    在msdn里有的是例程,自己去看看吧。
      

  4.   

    If you insist on having the service itself display the status, see 
    KB Article Q173687 "HOWTO: Access the Application Desktop from a Service"
    and 
    Q244651 "HOWTO: Creating a Shell Notification Icon from a Windows NT
    Service"
      

  5.   

    全局定义
    SERVICE_STATUS g_ssStatus;   
    SERVICE_STATUS_HANDLE g_sshStatusHandle;在启动时
    g_sshStatusHandle = RegisterServiceCtrlHandler(...);
    //当你要启动程序时,做如下设置
    g_ssStatus.dwCurrentState = SERVICE_STOP_PENDING;
    SetServiceStatus(g_sshStatusHandle, &g_ssStatus);
    //再在下面调用
    CreateProcess
    调用完了再把状态设置回去!