当前位置:主页>仓库管理软件> 列表

简单问题,高分求教!!!(调用winrar) 找医药进销存

记账软件版1楼: 我用Windows的API调用winrar来压缩文件,现在问题是,我想把许多文件压到一个包里,一个一个添的话,有时前一个没压完,后一个就往里加,会显示文件正用,压缩失败,我想问,怎么样解决这个问题,请各位大哥写出代码,谢谢。因为文件很多,我得一个一个往里添,我在线等,解决就给分

2楼: 你不一定要用API函數
Winrar有一個rar.exe命令。
用rar /?>rarReadme.txt可得到幫助文件。
例: rar a test.rar *.txt 如药品进销存管理

3楼: 用rar压缩有什么好处吗? 那么多压缩控件可用,vclzip, FlexCompress ,都非常好用,
哪怕是arj也是相当不错的,rar既不通用,又不免费,干吗要用它?

4楼: winexec(pchar(''c:\program files\winrar\winrar a ''+rarname+'' c:\zbsoft\glgcgl\fj\''+xmky),1);
我是这样调用的,跟你说的一样,出现的问题是前一个没压完,后一个就要往里加,出现了文件正用状态,压缩失败,

5楼: 软件已经做完,我在做维护,我想在不大改动的情况下,修改软件。

6楼: http://www.delphibbs.com/delphibbs/dispq.asp?lid=1171676

记账软件版7楼: 我的意思是說


可以調用winexec
var
str:String;
begin
str:=''rar a test.rar *.txt''; //可以自由組合
winexec(pchar(str), sw_hide);
如 rar a -pHello test.rar *.txt''
a是命令
-p是開關,加密碼。Hello就是密碼。
其他命令就自己慢慢看咯。

8楼: winexec(''d:\program files\winrar\winrar a c:\1.rar c:\1.bin c:\2.bin'', 0);

9楼: 我剛才試過
壓縮文件:winrar a -p[Hello] d:\test.rar *.txt *.key *.dll
壓縮兩個不同的目錄winrar a -p[Hello] d:\test.rar formats d:\tmp\a
也沒有問題。
format是Winrar下的目錄

10楼: To BrainYang, 我接受你的答案了,我现在去试试,我觉得这么做应该好用。

11楼: 我用了,还是有问题,我前边写压缩文件,后边写发送,大文件,没等我压完呢,程序自动到下一行,发送,结果没有压完就发出去了,是个坏的文件,怎么样做才能等压完再让它发送啊,比如有一个判断语句,if 没压完 then 等待,,,,else 发送压缩包,
这应该怎么写,请教

12楼: 從help來看,winExec執行如果成功,返回值會大于31。
我試了一下,似乎是大于33。
if winExec(''winrar a -p[Hello] d:\test.rar formats d:\tmp\a'',swHide)>33 then
//Do Something...
else
ShowMessage(''壓縮失敗!''); 如医药进销存

13楼: 压缩成不成功,我现在不在呼,我只关心的是,我发出的文件,是不是已经压完的,
如果没压完,就等待,可以这么做吗,

记账软件版14楼: //试试这一个, 来自 Peter Below(TeamB):
{-- WinExecAndWait32V2 ------------------------------------------------}
{: Executes a program and waits for it to terminate
@Param FileName contains executable + any parameters
@Param Visibility is one of the ShowWindow options, e.g. SW_SHOWNORMAL
@Returns -1 in case of error, otherwise the programs exit code
@Desc In case of error SysErrorMessage( GetlastError ) will return an
error message. The routine will process paint messages and messages
send from other threads while it waits.
}{ Created 27.10.2000 by P. Below
-----------------------------------------------------------------------}
Function WinExecAndWait32V2( FileName: String; Visibility: integer ): DWORD;


Procedure WaitFor( processHandle: THandle );
Var
msg: TMsg;
ret: DWORD;
Begin
Repeat
ret := MsgWaitForMultipleObjects(
1, { 1 handle to wait on }
processHandle, { the handle }
False, { wake on any event }
INFINITE, { wait without timeout }
QS_PAINT or { wake on paint messages }
QS_SENDMESSAGE { or messages from other threads }
);
If ret = WAIT_FAILED Then Exit; { can do little here }
If ret = (WAIT_OBJECT_0 + 1) Then Begin
{ Woke on a message, process paint messages only. Calling
PeekMessage gets messages send from other threads processed. }
While PeekMessage( msg, 0, WM_PAINT, WM_PAINT, PM_REMOVE ) Do
DispatchMessage( msg );
End;
Until ret = WAIT_OBJECT_0;
End; { Waitfor }
Var { V1 by Pat Ritchey, V2 by P.Below }
zAppName:array[0..512] of char;

StartupInfo:TStartupInfo;
ProcessInfo:TProcessInformation;
Begin { WinExecAndWait32V2 }
StrPCopy(zAppName,FileName);
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 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) { pointer to PROCESS_INF }
Then
Result := DWORD(-1) { failed, GetLastError has error code }
Else Begin
Waitfor(ProcessInfo.hProcess);
GetExitCodeProcess(ProcessInfo.hProcess, Result);


CloseHandle( ProcessInfo.hProcess );
CloseHandle( ProcessInfo.hThread );
End; { Else }
End; { WinExecAndWait32V2 }

下面是调用: 你把命令换成你需要的命令行就行了。不过还是建议你别用这个,就不怕用户没装rar啊? 还是你的软件自己带个盗版的rar。 唉。
procedure TForm1.Button2Click(Sender: TObject);
begin
WinExecAndWait32V2(''ping localhost'',SW_SHOWNORMAL);
ShowMessage(''ok'');
end;

15楼: 对了,估计你还不会,再说一点,SW_SHOWNORMAL参数是正常显示dos窗口,如果希望是后台执行的话,用SW_HIDE

16楼: 我想在原来的基础上,改一改,如果不行,就用压缩控件,
最好在原来的基础上改,

17楼: http://www.tomore.com/dispdocnew.php?id=35756

18楼: to : shangshang,太谢谢你了,问题解决了,我还要测试一下,先给分,
还有 BrainYang, 也谢谢你了,

19楼: 多人接受答案了。

20楼: 我恨你,不给我分!

记账软件版21楼: 哈哈,没办法,初学者总是不习惯别人给他URL.下次你也贴代码吧。