to: Michaelyfj(星星还是那颗星星) 我的email:[email protected]。to:outer2000(天外流星) 我用过这种方法,首先不适合有数据交互的情况,比如程序提示你输入x=?,而且不知为什么,我的命令行程序格式没有错误,但将结果输出到a.txt时却发现了系统提示的格式错误。 它只适用于简单的情况。to:Wally_wu(韦利) 具体该怎么用呢?我可以查查帮助,能否给各例子?谢谢。
//给你参考一下 //执行处部可执行文件 Function LaunchApp(pExePath,WorkDir:String;ShowWindow,WaitFlag:Boolean):Boolean; var ExePath : array[0..512] of char; StartupInfo:TStartupInfo; ProcessInfo:TProcessInformation; begin StrPCopy(exePath, pExePath); FillChar(StartupInfo,Sizeof(StartupInfo),#0); StartupInfo.cb := Sizeof(StartupInfo); StartupInfo.dwFlags := STARTF_USESHOWWINDOW; if ShowWindow then StartupInfo.wShowWindow := 1 else StartupInfo.wShowWindow := 0; if not CreateProcess(nil, ExePath, nil, nil, false, CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil, nil, StartupInfo, ProcessInfo) then begin Result:=False; Exit; end else begin if WaitFlag then WaitforSingleObject(ProcessInfo.hProcess,INFINITE); Result:=True; end; end;
vc好像也是这样。
具体例子没有,自己看看MSDN。
也发给俺,[email protected]
我的email:[email protected]。to:outer2000(天外流星)
我用过这种方法,首先不适合有数据交互的情况,比如程序提示你输入x=?,而且不知为什么,我的命令行程序格式没有错误,但将结果输出到a.txt时却发现了系统提示的格式错误。
它只适用于简单的情况。to:Wally_wu(韦利)
具体该怎么用呢?我可以查查帮助,能否给各例子?谢谢。
//执行处部可执行文件
Function LaunchApp(pExePath,WorkDir:String;ShowWindow,WaitFlag:Boolean):Boolean;
var ExePath : array[0..512] of char;
StartupInfo:TStartupInfo;
ProcessInfo:TProcessInformation;
begin
StrPCopy(exePath, pExePath);
FillChar(StartupInfo,Sizeof(StartupInfo),#0);
StartupInfo.cb := Sizeof(StartupInfo);
StartupInfo.dwFlags := STARTF_USESHOWWINDOW;
if ShowWindow then
StartupInfo.wShowWindow := 1
else
StartupInfo.wShowWindow := 0;
if not CreateProcess(nil,
ExePath,
nil,
nil,
false,
CREATE_NEW_CONSOLE or
NORMAL_PRIORITY_CLASS,
nil,
nil,
StartupInfo,
ProcessInfo) then begin
Result:=False;
Exit;
end else begin
if WaitFlag then
WaitforSingleObject(ProcessInfo.hProcess,INFINITE);
Result:=True;
end;
end;