D7zTool是一个基于7-zip库开发的解压缩示例程序,除了应用程序本身,仅包含一个7z.dll

主要界面:

D7zTool示例程序demo的pas源码

unit Unit1;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,D7zUtils,Dialogs, ComCtrls, StdCtrls, Menus;typeTForm1 = class(TForm)Edit1: TEdit;OpenDialog1: TOpenDialog;ListView1: TListView;btnOpenFile: TButton;PopupMenu1: TPopupMenu;N1: TMenuItem;SaveDialog1: TSaveDialog;procedure btnOpenFileClick(Sender: TObject);procedure FormCreate(Sender: TObject);procedure FormDestroy(Sender: TObject);procedure ListView1DblClick(Sender: TObject);procedure N1Click(Sender: TObject);private{ Private declarations }public{ Public declarations }FD7zipFile: TD7zipFile;procedure ShowPathItems(sPath: WideString);end;varForm1: TForm1;implementation
usessevenzip;{$R *.dfm}procedure TForm1.btnOpenFileClick(Sender: TObject);
beginif not OpenDialog1.Execute() then Exit;if not FD7zipFile.LoadFromFile(OpenDialog1.FileName) thenbeginShowMessage('打开失败');Exit;end;ShowPathItems('\\');
end;procedure TForm1.FormCreate(Sender: TObject);
beginFD7zipFile:=TD7zipFile.Create;
end;procedure TForm1.FormDestroy(Sender: TObject);
beginFD7zipFile.Free;
end;procedure TForm1.ListView1DblClick(Sender: TObject);
varsPath: WideString;
beginif ListView1.ItemFocused<>nil thenif Pos('2_', ListView1.ItemFocused.SubItems.Strings[1])=1 thenbeginsPath := ListView1.ItemFocused.Caption;if (sPath<>'.') and (sPath<>'..') and (FD7zipFile.CurrentItemPath<>'\\') thensPath := FD7zipFile.CurrentItemPath+sPath;ShowPathItems(sPath);end;
end;procedure TForm1.ShowPathItems(sPath: WideString);
varI: Integer;sList: TStrings;
beginListView1.Clear;//加文件夹sList := FD7zipFile.GetItems(sPath, 2);for I:=0 to sList.Count-1 dowith ListView1.Items.Add dobeginCaption := ExtractFileName(sList.Strings[I]);SubItems.Add('');SubItems.Add('2_文件夹');end;sList.Free;//加文件if sPath<>'' thensPath := FD7zipFile.CurrentItemPath;//转换为当前目录sList := FD7zipFile.GetItems(sPath, 1);for I:=0 to sList.Count-1 doif (sList.Strings[I]<>'.') and (sList.Strings[I]<>'..') thenwith ListView1.Items.Add dobeginCaption := ExtractFileName(sList.Strings[I]);SubItems.Add('');SubItems.Add('1_文件');end;sList.Free;Edit1.Text := FD7zipFile.CurrentItemPath;
end;procedure TForm1.N1Click(Sender: TObject);
varsFileName: WideString;
beginif ListView1.ItemFocused=nil then Exit;if Pos('1_', ListView1.ItemFocused.SubItems.Strings[1])<>1 then Exit;if not SaveDialog1.Execute then Exit;sFileName := ListView1.ItemFocused.Caption;if (FD7zipFile.CurrentItemPath<>'\\') thensFileName := FD7zipFile.CurrentItemPath+sFileName;FD7zipFile.ExtractItemToFile(sFileName, SaveDialog1.FileName);
end;end.

对应的dfm文件

object Form1: TForm1Left = 539Top = 114Width = 689Height = 412Caption = 'Form1'Color = clBtnFaceFont.Charset = DEFAULT_CHARSETFont.Color = clWindowTextFont.Height = -11Font.Name = 'MS Sans Serif'Font.Style = []OldCreateOrder = FalseOnCreate = FormCreateOnDestroy = FormDestroyPixelsPerInch = 96TextHeight = 13object Edit1: TEditLeft = 40Top = 48Width = 616Height = 21TabOrder = 0endobject ListView1: TListViewLeft = 40Top = 80Width = 616Height = 281Columns = <itemCaption = '文件名'Width = 200enditemCaption = '大小'Width = 100enditemCaption = '类型'Width = 100enditemCaption = '修改时间'Width = 100enditemCaption = '属性'Width = 100end>RowSelect = TruePopupMenu = PopupMenu1TabOrder = 1ViewStyle = vsReportOnDblClick = ListView1DblClickendobject btnOpenFile: TButtonLeft = 40Top = 8Width = 75Height = 25Caption = '打开文件'TabOrder = 2OnClick = btnOpenFileClickendobject OpenDialog1: TOpenDialogLeft = 592Top = 48endobject PopupMenu1: TPopupMenuLeft = 328Top = 184object N1: TMenuItemCaption = '解压'OnClick = N1Clickendendobject SaveDialog1: TSaveDialogLeft = 456Top = 136end
end

转载于:https://www.cnblogs.com/caibirdy1985/archive/2013/05/14/4232948.html

【Delphi】从内存读取或解压压缩文件(RAR、ZIP、TAR、GZIP等)(二)相关推荐

  1. python批量解压文件_python 批量解压压缩文件的实例代码

    下面给大家介绍python 批量解压压缩文件的实例代码,代码如下所述: #/usr/bin/python#coding=utf-8import os,sys import zipfile open_p ...

  2. R语言使用unzip函数解压压缩文件(Extract or List Zip Archives)

    R语言使用unzip函数解压压缩文件(Extract or List Zip Archives) 目录 R语言使用unzip函数解压压缩文件(Extract or List Zip Archives) ...

  3. php tp5在线解压压缩文件

    php tp5在线解压压缩文件 没啥原理,直接上代码把 解压方法 /*** 解压zip文件到指定目录* @param {string} $filepath: 文件路径* @param {string} ...

  4. http Content-Type (压缩文件 .rar .zip )

    http Content-Type (压缩文件 .rar .zip) application/octet-stream 和 application/x-zip-compressed

  5. centos 安装并使用rar解压压缩文件

    下载 下载自己的版本,下边以64位的为例: wget http://www.rarlab.com/rar/rarlinux-x64-5.6.1.tar.gz 解压 到文件夹/usr/local/rar ...

  6. Linux 解压 压缩文件

    1.*.tar 用 tar -xvf 解压 2.*.gz 用 gzip -d或者gunzip 解压 3.*.tar.gz和*.tgz 用 tar -xzf 解压 4.*.bz2 用 bzip2 -d或 ...

  7. 使用tar解压gz文件出现 “not in gzip format”错误解决办法

    我在解压.gz文件时使用的下面命令: tar -zxvf *.tar.gz 然后出现下面的提示: gzip: stdin: not in gzip format tar: Child returned ...

  8. 使用shell脚本一键式解压压缩文件

    话不多说,先上代码: #!/bin/bash cd /opt/software ----文件的目录位置 count=`ls -l | grep '^-' | wc -l` ----保存当前目录下的文件 ...

  9. Linux:shell 脚本 自动解压压缩文件tar.gz到指定目录

    具体情境 Ubuntu16.04系统,将.tar.gz格式的文件从/home/myftp/upload/nuodongiot目录自动解压到/home/myftp/upload/backupcopy目录 ...

最新文章

  1. mysql 压力测试之批量插入自增字段不连续问题
  2. MySQL SQL的概述
  3. 久其通用数据管理平台_银保行业通用的CRM系统,为你轻松化解庞大数据难题
  4. html 在tomcat中访问不到_安全服务之安全基线及加固(四)Tomcat篇
  5. 2017微服务 mysql集群_成功升P7多亏掌握了这几点:高并发+Nginx+微服务+Redis+MySQL...
  6. Swing编程基础 之三
  7. 轮子来袭 vJine.Core Orm 之 01_快速体验
  8. nginx配置注意事项1
  9. React 一些相关的技巧
  10. Git 将本地项目上传到Github
  11. 数据可视化之美:桑基图的前世今生
  12. “蔚来杯“2022牛客暑期多校训练营5 Don‘t Starve
  13. 【错误记录】Android Studio 编译报错 ( Module was compiled with an incompatible version of Kotlin. The binary )
  14. NLP 语义匹配:经典前沿方案整理
  15. Error during artifact deployment. See server log for details.解决方法
  16. 攻防世界 re insanity
  17. kali系统---DNS收集分析之dnsrecon
  18. trunk端口配置的PVID
  19. python学习遇到的英文词汇
  20. 在coursera上旁听深度学习课程

热门文章

  1. Flutter 绘图 Paint strokeCap 延伸类型 strokeJoin 拐角类型 图文分析
  2. Android中的webview详细使用
  3. Redhat 6.8部署oracle 12c
  4. 面对imbalance data的时候
  5. 洛谷P1434滑雪(逆向图的遍历搜索递归+记忆化,最长路问题)
  6. 转发: Angular装饰器
  7. 一张图轻松搞懂javascript event对象的clientX,offsetX,screenX,pageX区别
  8. appium定位元素java篇【转】
  9. c++11 stl 学习之 shared_ptr
  10. ie6,ie7,ie8 css bug兼容解决记录