奇怪了,为啥有它“〉”参数传不过去???(50分)

B

bbcock

Unregistered / Unconfirmed
GUEST, unregistred user!
我使用这段代码调用dos程序直到其执行完毕。
运行:WinexecAndWait32('程序.exe 文件 >输出结果,SW_SHOW);
我发现这个“〉”个符号好像无法作为参数传递给dos程序,一运行dos程序就报错,相同的内容在dos窗口运行就没问题,这是怎么回事?


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;
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 securityattributes }
nil, { pointer to thread securityattributes }
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,Result);
end;
end;
 
上次不是给你一个离子了吗!

WinExec(PChar('c:/windows/system32/cmd.exe /c abc.exe'+' > '+输出文件),SW_HIDE);
 
楼上这位大哥,小弟以前问过你这个问题吗?不会吧[?]

我需要程序等待dos运行结束后做下面的事,您的代码不行吧?
 
哎!
把WinExec的参数加入到 WinExecAndWait32就可以了吧!
 
顶部