我要用arj解压一个文件,要求不弹出解压过程的窗口且等待解压完毕再运行后面的程序。查了以前的贴子,还是不能解决。
请高手帮忙看一下。调试一下,谢谢。周一来结帖
1,没执行完毕就执行了后面的程序,
var
cmd:string;
begin
cmd:='arj.exe -y e test.arj';
winexec(pchar(cmd),sw_hide);
......
end;2.尽管不弹出窗口,但那个隐藏的窗口不会自动关闭,所以后面的程序不会执行,造成程序假死机现象。
var
cmd:string;
begin
cmd:='arj.exe -y e test.arj';
winexec(pchar(cmd),sw_hide);
WinExecAndWait32(cmd,1);
......
end;//函数
function TForm1.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;
StartupInfo.wShowWindow :=SW_HIDE; if not CreateProcess(nil,
zAppName, { pointer to command line string }
nil, { pointer to process security attributes }
nil, { pointer to thread security attributes }
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);
Result := 0;
end;end;
请高手帮忙看一下。调试一下,谢谢。周一来结帖
1,没执行完毕就执行了后面的程序,
var
cmd:string;
begin
cmd:='arj.exe -y e test.arj';
winexec(pchar(cmd),sw_hide);
......
end;2.尽管不弹出窗口,但那个隐藏的窗口不会自动关闭,所以后面的程序不会执行,造成程序假死机现象。
var
cmd:string;
begin
cmd:='arj.exe -y e test.arj';
winexec(pchar(cmd),sw_hide);
WinExecAndWait32(cmd,1);
......
end;//函数
function TForm1.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;
StartupInfo.wShowWindow :=SW_HIDE; if not CreateProcess(nil,
zAppName, { pointer to command line string }
nil, { pointer to process security attributes }
nil, { pointer to thread security attributes }
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);
Result := 0;
end;end;
解决方案 »
- DELPHI里面用QuickRep控件打印效果与打印预览不一致
- 求delphi的电子书
- 急问简单的图像翻转及拖动
- 新手请教问题。一个interbase 建表时用的语句 急 在线等。
- 高手都不见了吗?来帮帮小弟吧!分不够再加
- 如何把格式为#,##0.00形式的数据转化成合法的float型?
- 如何将一个WEB页面中所有的表格的内容提取出来???
- 对Borland愤怒中,真是龌龊,大家警惕了!
- To:tikkypeng(一两狂死郎之天衣有缝) 帮我看看这个问题好吗? http://www.csdn.net/expert/topic/357/357383.shtm(无内容)
- 新文章发布(DELPHI版)
- delphi7 mysql问题
- 关于使用Socket传输大文件的时候,怎样保证数据无误的传输?
var
cmd:string;
begin
cmd:='arj.exe -y e test.arj';
/////去掉这个winexec(pchar(cmd),sw_hide);
WinExecAndWait32(cmd,1);
......
end;
var
cmd:string;
begin
cmd:='arj.exe -y e test.arj'; //winexec(pchar(cmd),sw_hide);
//你应把winexec(pchar(cmd),sw_hide);这行屏蔽掉 WinExecAndWait32(cmd,1);
end;
var
cmd:string;
begin
cmd:='arj.exe -y e test.arj';
//winexec(pchar(cmd),sw_hide);
WinExecAndWait32(cmd,1);showmessage('over');
end;屏蔽了那一行程序还是不执行啊。最后的一个提示框怎么不出来呢?
procedure TForm1.BitBtn1Click(Sender: TObject);
var
cmd:string;
begin
cmd:='arj.exe -y e test.arj';
WinExecAndWait32(cmd,1);
ShowMessage('Ok');
end;你再试试,不是点错按钮了吧?