procedure TForm1.Button1Click(Sender: TObject);
var
si: TStartupInfo;
pi: TProcessInformation;
s: string;
b: boolean;
dw: DWORD;
begin
Button1.Caption:='elindult ...';
Button1.Update;
FillChar(si, SizeOf(TStartupInfo), 0);
with si do begin
cb:=SizeOf(TStartupInfo);
dwFlags:=STARTF_USESHOWWINDOW+
STARTF_FORCEONFEEDBACK;
wShowWindow:=SW_SHOW;
end;
s:=ExtractFilePath(Application.ExeName);
Delete(s, Length(s)-1, 2);
s:=s+'B\project1.exe';
b:=CreateProcess(nil, PChar(s), nil, nil, false,
NORMAL_PRIORITY_CLASS, nil, nil, si, pi);
if b then begin
WaitForInputIdle(pi.hProcess, INFINITE);
WaitForSingleObject(pi.hProcess, INFINITE);
GetExitCodeProcess(pi.hProcess, dw);
CloseHandle(pi.hThread);
CloseHandle(pi.hProcess);
Button1.Caption:='ExitCode '+IntToStr(dw);
end else begin
Button1.Caption:='A másik program elindítása sikertelen!';
end;
end;