?? terminate.pas
字號:
unit Terminate;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Label1: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
ProcessInfo: TProcessInformation; // holds process information
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
StartUpInfo: TStartUpInfo; // holds startup information
begin
{initialize the startup information}
FillChar(StartupInfo, SizeOf(TStartupInfo), 0);
with StartupInfo do
begin
cb := SizeOf(TStartupInfo);
dwFlags := STARTF_USESHOWWINDOW;
wShowWindow := SW_SHOWNORMAL;
end;
{launch a process}
CreateProcess('c:\Windows\calc.exe', nil, nil, nil, False,
NORMAL_PRIORITY_CLASS, nil, nil, StartupInfo, ProcessInfo);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
ExitCode: DWORD; // holds the process exit code
begin
{terminate the process and retrieve the exit code}
TerminateProcess(ProcessInfo.HProcess, 10);
GetExitCodeProcess(ProcessInfo.HProcess, ExitCode);
{display the exit code}
Label1.Caption := 'The exit code is '+Inttostr(ExitCode);
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -