永发信息网

vb怎么解压

答案:2  悬赏:70  手机版
解决时间 2021-05-01 11:52
  • 提问者网友:伴风望海
  • 2021-04-30 19:53
WinRaR把文件夹等压缩成包再放入VB资源文件里!释放它的时候先释放再调用命令行解压。这个怎么实现啊
最佳答案
  • 五星知识达人网友:神也偏爱
  • 2021-04-30 21:29
'一、建立模块MDWinrar.bas,复制下面代码
Declare Function WaitForSingleObject Lib "kernel32" _
    (ByVal hHandle As Long, ByVal dwMilliseconds As Long) _
    As Long
Declare Function OpenProcess Lib "kernel32" (ByVal _
    dwDesiredAccess As Long, ByVal bInheritHandle As Long, _
    ByVal dwProcessId As Long) As Long
Declare Function GetShortPathName Lib "kernel32" Alias _
    "GetShortPathNameA" (ByVal lpszLongPath As String, _
    ByVal lpszShortPath As String, ByVal cchBuffer As _
    Long) As Long
Private Const INFINITE = -1&
Private Const SYNCHRONIZE = &H100000
Sub RarExect(Rarml As String) '等待winrar解压结束
    Dim TaskID As Long    ' Task-ID des DOS-Fensters
    Dim ProcID As Long    ' Prozess-ID des DOS-Fensters
    TaskID = Shell(Rarml, vbHide)
    DoEvents
    ProcID = OpenProcess(SYNCHRONIZE, False, TaskID)
    Call WaitForSingleObject(ProcID, INFINITE)
End Sub
'二、程序调用如下:
private command1_click()
'本功能执行了把c:\mydoctment file\blank.zip文件解压到d:\tmp下。
RarExect "c:\winrar\winrar.exe e -y "  & ShortPath("c:\mydoctment file\blank.zip" & " "  & ShortPath("d:\tmp")
end sub
全部回答
  • 1楼网友:春色三分
  • 2021-04-30 22:12

winrar官方网站上有提供VB调用的示例,

你下载来看看就明白了

我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯