⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 terminate.pas

📁 Delphi Win32核心API参考光盘源码 本书包含了常用的Windows API函数
💻 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 + -