function tfmain.runwait (filename:string; Visibility:integer): Thandle;
Var
ZAPPNAME:ARRAY[0..512] of Char;
ZCURDIR:ARRAY[0..255] of Char;
workdir:string;
Startupinfo:tstartupinfo;
Processinfo:tprocessinformation;
Begin
Try
Strpcopy (Zappname, FileName);
Getdir (0, Workdir);
Strpcopy (Zcurdir, Workdir);
Fillchar (Startupinfo, SizeOf (startupinfo), #0);
STARTUPINFO.CB: = SizeOf (Startupinfo);
Startupinfo.dwflags: = Startf_useshowwindow;
Startupinfo.wshowwindow: = Visibility;
If not CreateProcess (nil, zappname, nil, nil, false, create_new_console or normal_priority_class, nil, nil, startupinfo, P Rocessinfo) Then
Begin
Result: = 0;
Exit;
End
Else
Begin
WaitForSingleObject (processinfo.hprocess, INFINITE);
GetExitCodeProcess (processinfo.hprocess, result);
End
Finally
End
End
Call
Procedure Tfmain.img_buyclick (Sender:tobject);
Var
msg:string;
Begin
timer1.enabled: = False;
Runwait (' Cs_buy.exe ', sw_showmaximized);
timer1.enabled: = True;
End
Where the parameter Visibility value is as follows:
Line number parameter meaning
1 sw_hide hides this form and activates other forms.
2 Sw_maximize maximizes the specified form.
3 sw_minimize minimizes the specified form and activates the topmost form sequentially.
4 Sw_restore activates and displays the form. If the form is minimized or maximized, the form reverts to the original large
Small and set. The application specifies the markup when a minimized form is restored.
5 Sw_show activates and displays the form at its current size and position.
6 Sw_showdefault
7 sw_showmaximized activates and maximizes the display of the form.
8 sw_showminimized activates and minimizes the reality form.
9 sw_showminnoactive Minimize the form and keep it active.
Sw_showna displays the form in its current state, keeping it active.
Sw_shownoactivate displays the form in its current size and position and retains its active status.
Sw_shownormal activates and displays a form. If the form is maximized or minimized, the form reverts to its original size and position. When the form is first displayed, the application records the markup
Delphi calls the external EXE and waits for the calling program to run end