unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
StartupInfo:TStartupInfo;
ProcessInfo:TProcessInformation;
implementation
{$R *.DFM}
function WinExecExW(cmd,workdir
char;visiable:integer)
WORD;
begin
FillChar(StartupInfo,SizeOf(StartupInfo),#0);
StartupInfo.cb:=SizeOf(StartupInfo);
StartupInfo.dwFlags:=STARTF_USESHOWWINDOW;
StartupInfo.wShowWindow:=visiable;
if not CreateProcess(nil,cmd,nil,nil,false,Create_new_console or Normal_priority_class,nil,nil,StartupInfo,ProcessInfo) then
result:=0
else
Result:=1;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
WinExecExW('g:/project1.exe','',1)
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
TerminateProcess(ProcessInfo.hProcess,0);
end;
end.