function ExecShowModal(APath: PChar; ACmdShow: Integer; ATimeout: Longword): Integer; var vStartupInfo: TStartupInfo; vProcessInfo: TProcessInformation; begin FillChar(vStartupInfo, SizeOf(TStartupInfo), 0); with vStartupInfo do begin cb := SizeOf(TStartupInfo); dwFlags := STARTF_USESHOWWINDOW or STARTF_FORCEONFEEDBACK; wShowWindow := ACmdShow; end; if CreateProcess(nil, APath, nil, nil, False, NORMAL_PRIORITY_CLASS, nil, nil, vStartupInfo, vProcessInfo) then Result := WaitForSingleObject(vProcessInfo.hProcess, ATimeout) else Result := GetLastError; end; procedure TForm1.Button3Click(Sender: TObject); begin ExecShowModal(‘notepad.exe‘, SW_SHOW, INFINITE); end;
参考:http://www.cnblogs.com/key-ok/p/3358855.html
时间: 2024-10-09 18:41:24