| 首页 | 电脑常识 | 程序设计 | 操作系统 | 语法 | 病毒安全 | 软件教程 | 硬件 | 数据库 | 多媒体 | 认证 | 下载 | 
首页>>程序设计 >>综合
Tips 挂起 - 运行外部程式,外部程式退出 - 继续执行

Tips 挂起 - 运行外部程式,外部程式退出 - 继续执行

电脑学习网,xuef.com,最全最新最权威的电脑知识网站.
免费计算机学习教程,电脑入门指南.


function WinExecAndWait32(FileName:String; Visibility : integer):integer;
var
  zAppName : array[0..512] of char;
  zCurDir  : array[0..255] of char;
  WorkDir  : String;
  StartupInfo:TStartupInfo;
  ProcessInfo:TProcessInformation;
  lpExitCode : Cardinal;
begin
  StrPCopy(zAppName, FileName);
  GetDir(0, WorkDir);
  StrPCopy(zCurDir,WorkDir);
  FillChar(StartupInfo,Sizeof(StartupInfo),#0);
  StartupInfo.cb := Sizeof(StartupInfo);

  StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
  StartupInfo.wShowWindow := Visibility;
  if not CreateProcess(nil,
    zAppName,                     { pointer to command line string }
    nil,                                   { pointer to process security attributes }
    nil,                                   { pointer to thread security attributes }
    false,                                { handle inheritance flag }
    CREATE_NEW_CONSOLE or          { creation flags }
    NORMAL_PRIORITY_CLASS,
    nil,                           { pointer to new environment block }
    nil,                           { pointer to current directory name }
    StartupInfo,                   { pointer to STARTUPINFO }
    ProcessInfo) then Result := -1 { pointer to PROCESS_INF }

  else begin
    WaitforSingleObject(ProcessInfo.hProcess,INFINITE);
    GetExitCodeProcess(ProcessInfo.hProcess, lpExitCode);
    Result := lpExitCode;
  end;
end;

整理:lzcx

相 关 文 章
  • 判断MonthCalander中鼠标点中了日期还是翻页按钮!

  • 用Delphi实现整个网站图片的极速下载

  • Delphi控制Excel2000

  • 用DELPHI实现文件加密压缩

  • Delphi控制Excel的重要属性和方法

  • Windows的DDE原理

  • 在Delphi中获取和修改文件的时间

  • 校验码辅导讲座

  • 在Delphi 7中用dbexpress连接MySQL

  • Delphi:Daily build实践

  • 学府网电脑学习的乐园
    中国电脑教学网,电脑爱好者的乐园,做最好最全的计算机学习网站.