如何在服务中启动一个可执行程序?(100分)

W

wlw88

Unregistered / Unconfirmed
GUEST, unregistred user!
我的下列程序在启动服务时,提示错误,不能启动!不知道错在哪儿,谢谢!!<br>unit Start1;<br><br>interface<br><br>uses<br>&nbsp; Windows, Messages, SysUtils, Classes, Graphics, Controls, SvcMgr, Dialogs;<br><br>type<br>&nbsp; TTapStart = class(TService)<br>&nbsp; &nbsp; procedure ServiceExecute(Sender: TService);<br>&nbsp; private<br>&nbsp; &nbsp; { Private declarations }<br>&nbsp; public<br>&nbsp; &nbsp; function GetServiceController: TServiceController; override;<br>&nbsp; &nbsp; { Public declarations }<br>&nbsp; end;<br><br>var<br>&nbsp; TapStart: TTapStart;<br><br>implementation<br><br>{$R *.DFM}<br><br>procedure ServiceController(CtrlCode: DWord); stdcall;<br>begin<br>&nbsp; TapStart.Controller(CtrlCode);<br>end;<br><br>function TTapStart.GetServiceController: TServiceController;<br>begin<br>&nbsp; Result := ServiceController;<br>end;<br><br>procedure TTapStart.ServiceExecute(Sender: TService);<br>begin<br>&nbsp;WinExec(Pchar(getcurrentdir+'/Tap.exe'),SW_SHOW);<br>&nbsp;end;<br><br>end.<br>
 
提示什么错误?
 
你必需新建一个线程,在线程中再去启动程序。
 
to htw在启动的时候提示有一个Windows程序不能启动!<br>to 远帆,你说的好像不对吧,我试过了也不行的,其实根本就不用新建线程!<br>
 
谁说不需要新建线程呢?<br>我试过,在线程中是可以启动程序的。不过看不到。<br>我猜想可能是因为它的父进程是不可显示的,所以不能显示?
 
的确,我也遇见了这样的问题、在服务程序中可以启动程序的、不过看不到<br>我也很想能得到解决的方法,那位高手知道,请指点!<br>
 
顶部