DOS命令是 【D:\压缩文件.exe < D:password.txt】 可执行因是带密码的压缩文件,每次执行要输入密码。
所以把密码放入文本文件中。可是用下列代码不起作用procedure ShellExecute_AndWait(CMDLine: string; Params: string);
var
exInfo: TShellExecuteInfo; //引用uses shellapi
Ph: DWORD;
cmdbuffer: array [0..MAX_PATH] of Char;
begin
FillChar(exInfo, SizeOf(exInfo), 0);
with exInfo do begin
cbSize := SizeOf(exInfo);
fMask := SEE_MASK_NOCLOSEPROCESS or SEE_MASK_FLAG_DDEWAIT;
Wnd := GetActiveWindow();
ExInfo.lpVerb := 'open';
ExInfo.lpParameters := PChar(Params);
lpFile := PChar(CMDLine);
nShow := SW_SHOWNORMAL;
end; if ShellExecuteEx(@exInfo) then
Ph := exInfo.HProcess
else begin
ShowMessage(SysErrorMessage(GetLastError));
Exit;
end; while WaitForSingleObject(ExInfo.hProcess, 50) <> WAIT_OBJECT_0 do
Application.ProcessMessages; CloseHandle(Ph);
end;——————————————————————————————
若是【D:\压缩文件.exe】没问题,
但是【D:\压缩文件.exe < D:password.txt】 出错。Help me!
所以把密码放入文本文件中。可是用下列代码不起作用procedure ShellExecute_AndWait(CMDLine: string; Params: string);
var
exInfo: TShellExecuteInfo; //引用uses shellapi
Ph: DWORD;
cmdbuffer: array [0..MAX_PATH] of Char;
begin
FillChar(exInfo, SizeOf(exInfo), 0);
with exInfo do begin
cbSize := SizeOf(exInfo);
fMask := SEE_MASK_NOCLOSEPROCESS or SEE_MASK_FLAG_DDEWAIT;
Wnd := GetActiveWindow();
ExInfo.lpVerb := 'open';
ExInfo.lpParameters := PChar(Params);
lpFile := PChar(CMDLine);
nShow := SW_SHOWNORMAL;
end; if ShellExecuteEx(@exInfo) then
Ph := exInfo.HProcess
else begin
ShowMessage(SysErrorMessage(GetLastError));
Exit;
end; while WaitForSingleObject(ExInfo.hProcess, 50) <> WAIT_OBJECT_0 do
Application.ProcessMessages; CloseHandle(Ph);
end;——————————————————————————————
若是【D:\压缩文件.exe】没问题,
但是【D:\压缩文件.exe < D:password.txt】 出错。Help me!
可是又出现新的问题了。
当密码不对时,该执行文件会让重新输入密码。如何取到可执行文件的结果,并给它输入密码。