这个你也许用得上
Q: How to execute a program and wait till it finishes (WIN 32).A: function ProcessFG(const Filename, Arguments: String;
const WindowState: Word): Boolean; var
StartUpInformation : TStartupInfo;
ProcessInformation : TProcessInformation;
CommandLine : String; begin // build command line
//
CommandLine := Filename + ' ' + Arguments; // initialize start up information
//
FillChar(StartUpInformation, SizeOf(TStartUpInfo), Chr(0));
StartUpInformation.cb := SizeOf(TStartUpInfo);
StartUpInformation.dwFlags := STARTF_USESHOWWINDOW;
StartUpInformation.wShowWindow := WindowState; // spawn process
//
Result := CreateProcess(nil, PChar(CommandLine),
nil, nil, FALSE,
CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil,
PChar(ExtractFilePath(Filename)), StartUpInformation,
ProcessInformation); // wait for process to finish if created
//
if Result then WaitForSingleObject(ProcessInformation.hProcess, INFINITE);
end;
Q: How to execute a program and wait till it finishes (WIN 32).A: function ProcessFG(const Filename, Arguments: String;
const WindowState: Word): Boolean; var
StartUpInformation : TStartupInfo;
ProcessInformation : TProcessInformation;
CommandLine : String; begin // build command line
//
CommandLine := Filename + ' ' + Arguments; // initialize start up information
//
FillChar(StartUpInformation, SizeOf(TStartUpInfo), Chr(0));
StartUpInformation.cb := SizeOf(TStartUpInfo);
StartUpInformation.dwFlags := STARTF_USESHOWWINDOW;
StartUpInformation.wShowWindow := WindowState; // spawn process
//
Result := CreateProcess(nil, PChar(CommandLine),
nil, nil, FALSE,
CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil,
PChar(ExtractFilePath(Filename)), StartUpInformation,
ProcessInformation); // wait for process to finish if created
//
if Result then WaitForSingleObject(ProcessInformation.hProcess, INFINITE);
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货