我写了一个服务程序,在系统启动时候自动启动
然后在某种情况下,希望由服务程序启动另外一个exe执行文件
我试了用
ShellExecute
WinExec
CreateProcess同样的语句,在普通程序里面可以启动另外一个程序(例如notepad.exe)
但是在服务程序里面就没有反应了请各位指教!
然后在某种情况下,希望由服务程序启动另外一个exe执行文件
我试了用
ShellExecute
WinExec
CreateProcess同样的语句,在普通程序里面可以启动另外一个程序(例如notepad.exe)
但是在服务程序里面就没有反应了请各位指教!
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.
KB Article Q173687 "HOWTO: Access the Application Desktop from a Service"
and
Q244651 "HOWTO: Creating a Shell Notification Icon from a Windows NT
Service"
SERVICE_STATUS g_ssStatus;
SERVICE_STATUS_HANDLE g_sshStatusHandle;在启动时
g_sshStatusHandle = RegisterServiceCtrlHandler(...);
//当你要启动程序时,做如下设置
g_ssStatus.dwCurrentState = SERVICE_STOP_PENDING;
SetServiceStatus(g_sshStatusHandle, &g_ssStatus);
//再在下面调用
CreateProcess
调用完了再把状态设置回去!