project1.dpr

来自「用于演示一种应用程序崩溃后自动重启的编程技巧」· DPR 代码 · 共 36 行

DPR
36
字号
program Project1;

uses
  Forms,System,Windows,
  Unit1 in 'Unit1.pas' {Form1};

{$R *.res}
var
  hReadPipe,hWritePipe:THandle;
  strBuff:array[0..255] of char;

  WorkDir,mns:String;
  StartupInfo:TStartupInfo;
  ProcessInfo:TProcessInformation;
  
begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;

  FillChar(StartupInfo,Sizeof(StartupInfo),#0);
  StartupInfo.cb:=Sizeof(StartupInfo);
  
  if Form1.g_bIsRunAgain then
  CreateProcess(nil,
    PChar(Application.exename),               { pointer to command line string }
    nil,                           { pointer to process security attributes }
    nil,                           { pointer to thread security attributes }
    False,                          { handle inheritance flag }
    NORMAL_PRIORITY_CLASS,
    nil,                           { pointer to new environment block }
    nil,                { pointer to current directory name, PChar}
    StartupInfo,                   { pointer to STARTUPINFO }
    ProcessInfo);                 { pointer to PROCESS_INF }
end.

⌨️ 快捷键说明

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