1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
Public Nom As String
Declare Function OpenProcess Lib "kernel32" _
(ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long
Declare Function GetExitCodeProcess Lib "kernel32" _
(ByVal hProcess As Long, _
lpExitCode As Long) As Long
Public Const PROCESS_QUERY_INFORMATION = &H400
Public Const STILL_ACTIVE = &H103
Public Sub ShellAndWait(ByVal PathName As String, Optional WindowState)
Dim hProg As Long
Dim hProcess As Long, ExitCode As Long
If IsMissing(WindowState) Then WindowState = 1
hProg = Shell(PathName, WindowState)
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, hProg)
Do
GetExitCodeProcess hProcess, ExitCode
DoEvents
Loop While ExitCode = STILL_ACTIVE
End Sub
Sub Dezipper()
Dim CheminZip As String
Dim DossierUnZip As String
Dim FichierZip As Variant, ShellStr As String
CheminZip = "C:\program files\7-Zip\"
If Right(CheminZip, 1) <> "\" Then
CheminZip = CheminZip & "\"
End If
If Dir(CheminZip & "7z.exe") = "" Then
Exit Sub
End If
DossierUnZip = "C:\Divers\Archives\"
FichierZip = "C:\Divers\Archives\" & Nom
ShellStr = CheminZip & "7z.exe x -aoa -r" _
& " " & Chr(34) & FichierZip & Chr(34) _
& " -o" & Chr(34) & DossierUnZip & Chr(34) & " " & "*.*"
ShellAndWait ShellStr, vbHide
End Sub |
Partager