unit1.pas

来自「Delphi7应用编程150例附书源码.rar」· PAS 代码 · 共 62 行

PAS
62
字号
unit Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TfrmMain = class(TForm)
    btnSuspend: TButton;
    btnResume: TButton;
    procedure btnSuspendClick(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure btnResumeClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmMain: TfrmMain;
  lpProcessInformation: TProcessInformation;
  bCreateProcess: boolean;

implementation
{$R *.dfm}

procedure TfrmMain.btnSuspendClick(Sender: TObject);
begin
    if bCreateProcess then
    begin
        SuspendThread(lpProcessInformation.hThread);
    end;
end;

procedure TfrmMain.FormCreate(Sender: TObject);
var
  lpStartupInfo: TStartupInfo;
begin
  FillChar(lpStartupInfo, Sizeof(TStartupInfo), #0);
  lpStartupInfo.cb := Sizeof(TStartupInfo);
  lpStartupInfo.dwFlags := STARTF_USESHOWWINDOW;
  lpStartupInfo.wShowWindow := SW_NORMAL;
  bCreateProcess := CreateProcess('C:\winnt\Notepad.exe',nil, nil, nil,
                                True, NORMAL_PRIORITY_CLASS, nil, nil,
                                lpStartupInfo, lpProcessInformation);
  if bCreateProcess then
  begin
    ShowMessage('启动成功');
  end;
end;

procedure TfrmMain.btnResumeClick(Sender: TObject);
begin
    if bCreateProcess then
    begin
        ResumeThread(lpProcessInformation.hThread);
    end;
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?