求DELPHI中的解rar压缩文件包的代码,希望不是直接调用EXE可执行文件,可以在没有安装RAR的时候也可以解压。
下面是一个网上搜索到的。
但是里面的参数实在是不好参悟啊。谁有好的发下,谢谢
function jieyabao(rarpath, typer, openpath, jiepath: string):integer;
//(1) 功 能 : 解压数据包rar文件
//(2) 参 数 :
//(3) 返回值 : 0 成功 1错误
//(4) 作成者 : 撖牛牛
//
var
SUInfo: TStartupInfo;
ProcInfo: TProcessInformation;
str1:pchar;
begin
FillChar(SUInfo, SizeOf(SUInfo), 0);
with SUInfo do
begin
cb := SizeOf(SUInfo);
dwFlags := STARTF_USESHOWWINDOW or STARTF_FORCEONFEEDBACK;
wShowWindow := SW_SHOW;
end;
str1:=pchar(rarpath+ typer+ openpath +jiepath);
if CreateProcess(nil,str1, nil, nil, False,
CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil,nil, SUInfo, ProcInfo) then
begin // pchar(rarpath+ typer+ openpath +jiepath)
WaitForSingleObject(ProcInfo.hProcess, INFINITE);
CloseHandle(ProcInfo.hProcess);
CloseHandle(ProcInfo.hThread);
result:=0;
end else
begin
result:=1;
end;
end;
下面是一个网上搜索到的。
但是里面的参数实在是不好参悟啊。谁有好的发下,谢谢
function jieyabao(rarpath, typer, openpath, jiepath: string):integer;
//(1) 功 能 : 解压数据包rar文件
//(2) 参 数 :
//(3) 返回值 : 0 成功 1错误
//(4) 作成者 : 撖牛牛
//
var
SUInfo: TStartupInfo;
ProcInfo: TProcessInformation;
str1:pchar;
begin
FillChar(SUInfo, SizeOf(SUInfo), 0);
with SUInfo do
begin
cb := SizeOf(SUInfo);
dwFlags := STARTF_USESHOWWINDOW or STARTF_FORCEONFEEDBACK;
wShowWindow := SW_SHOW;
end;
str1:=pchar(rarpath+ typer+ openpath +jiepath);
if CreateProcess(nil,str1, nil, nil, False,
CREATE_NEW_CONSOLE or NORMAL_PRIORITY_CLASS, nil,nil, SUInfo, ProcInfo) then
begin // pchar(rarpath+ typer+ openpath +jiepath)
WaitForSingleObject(ProcInfo.hProcess, INFINITE);
CloseHandle(ProcInfo.hProcess);
CloseHandle(ProcInfo.hThread);
result:=0;
end else
begin
result:=1;
end;
end;
Delphi component wrapper for UnRar.dll http://www.rarlab.com/rar/TDFUnRar.zip
http://www.rarlab.com/rar/TDFUnRar.zipUnRAR Delphi component Delphi component wrapper for UnRar.dll by Philippe Wechsler.
http://www.rarlab.com/rar/RARComponent_12.zip
除非你是要单独作一个这样的商品软件。
winrar.exe e -y C:\test.rar d:\ 解压test.rar到D盘
LZ可以去官网看看
下载winrar提供的动态链接库unrar.dll
http://www.rarlab.com/rar/UnRARDLL.exe(需解压) 这里解压到那里??
下载为delphi提供的组件并安装
http://www.rarlab.com/rar/TDFUnRar.zip
下载完了编译报错:
could not create output file c:\program files\borland\delphi6\....
谁知道什么情况?
在界面上添加安装的组件DFUnRar1
解压的代码为
with DFUnRar1 do
begin
Directory := ExtractFilePath(Application.ExeName); //解压的目标目录
FileName := 'aa.rar'; //你需要解压的文件名,如果不放在相同目录下,需要设置全路径
Mode := DFRAR_EXTRACT;
OverrideEvent := OR_ALWAYS;
//Password := '文件的密码';
Extract;
end;
以上只是提供简单的说明,
事实上能做到更多,大家自己看demo吧,就在上面第二个文件中