这个.........用你的程序来启动那个公司的程序
再开个定时器来定时检测程序进程的的顶层窗口是否为提示框,如果是就暂停...
应该行吧,看看下面这个例子:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Timer1: TTimer;
Timer2: TTimer;
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
private
{ Private declarations }
stinfo:TStartUpInfo;
proinfo:TProcessInformation;
i:integer;
public
{ Public declarations }
end;
function EnumerateWindows(hWnd: HWND; pid:cardinal):boolean;stdcall;
var
Form1: TForm1;
implementation
{$R *.dfm}
function EnumerateWindows(hWnd: HWND; pid:cardinal):boolean;
var
str: Array[0..255] of char;
hp:dword;
begin
result:=true;
GetWindowThreadProcessId(hWnd,@hp);
if (hp=pid) and IsWindowVisible(hWnd) then
begin
GetClassName(hWnd, str, 255);
if sametext(str,'#32770') then {遇到对话框窗体就停止}
begin
form1.Timer1.Enabled:=false;
result:=false;
end
else
form1.Timer1.Enabled:=true;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
FillChar(stinfo, sizeof(TStartupInfo), 0);
stinfo.cb:=sizeof(stinfo); {启动要检测的程序}
CreateProcess(pchar('d:/test.exe'),nil,nil,nil,false,
Create_new_console or Normal_priority_class,nil,nil,stinfo,proinfo);
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
self.Caption:=inttostr(i);
inc(i);
end;
procedure TForm1.Timer2Timer(Sender: TObject);
var
i:cardinal;
begin
GetExitCodeProcess(proinfo.hProcess,i);
if i=STILL_ACTIVE then
EnumWindows(@EnumerateWindows,proinfo.dwProcessId);
end;
end.