unit1.pas

来自「Windows CMD Emulator is Based Upon Creat」· PAS 代码 · 共 64 行

PAS
64
字号
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, UnitCMD, XPMan;

type
  TForm1 = class(TForm)
    mOutput: TMemo;
    edCommand: TEdit;
    Button2: TButton;
    XPManifest1: TXPManifest;
    procedure Button2Click(Sender: TObject);
    procedure edCommandKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button2Click(Sender: TObject);
var
 P:PShellThread;
begin
 if Button2.Caption = 'Enable' then
 Begin
  New(P);
  mOutput.Clear;
  P.OutputMemo := mOutput;
  CreateThread(nil, 0, @ShellThread, P, 0, ShellThreadID);
  Button2.Caption := 'Disable';
  edCommand.Enabled := True;
  mOutput.Enabled := True;
 end else
 begin
  if ShellThreadID <> 0 then PostThreadMessage(ShellThreadID, WM_ACTIVATE, Length('exit'), DWord(String(pChar('exit'))));
  Button2.Caption := 'Enable';
  edCommand.Enabled := False;
  mOutput.Enabled := False;
 end;
end;

procedure TForm1.edCommandKeyDown(Sender: TObject; var Key: Word;
  Shift: TShiftState);
begin
 if Key = 13 then
 begin
  if ShellThreadID <> 0 then PostThreadMessage(ShellThreadID, WM_ACTIVATE, Length(edCommand.Text), DWord(pChar(edCommand.Text)));
  edCommand.Text := '';
 end;
end;

end.

⌨️ 快捷键说明

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