Probléme de dezzipage

kelustar - 2 oct. 2012 à 10:59
cs_Jack Messages postés 14006 Date d'inscription samedi 29 décembre 2001 Statut Modérateur Dernière intervention 28 août 2015 - 3 oct. 2012 à 16:34
Bonjour,

Je souhaiterais pouvoir dézipper un fichier présent dans une archive 7zip protégée par un mot de passe. Voici mon code :


----------------------------------------------------------------

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, _
ByVal lpExitCode As Long) As Long

Public Const PROCESS_QUERY_INFORMATION = &H400
Public Const STILL_ACTIVE = &H103

Public Sub ShellAndWait(ByVal PathName As String)

Dim hProg As Long
Dim hProcess As Long, ExitCode As Long

hProg = Shell(PathName)
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION, False, hProg)
Do
GetExitCodeProcess(hProcess, ExitCode)
Loop While ExitCode = STILL_ACTIVE
End Sub

-----------------------------------------------------------------------------

Sub Dezipper()

Dim CheminZip As String
Dim DossierUnZip As String
Dim FichierZip As Object, ShellStr As String

CheminZip = "C:\program files\7-Zip"

DossierUnZip = "C:"
FichierZip = "C:\ok.7z"
ShellStr = CheminZip & "7z.exe x -aoa -r" _
& " " & Chr(34) & FichierZip & Chr(34) _
& " -o" & Chr(34) & DossierUnZip & Chr(34) & " " & "*.*"

ShellAndWait(ShellStr)

End Sub

--------------------------------------------------------------------------

Ce programme dézippe bien mon fichier mais lorsque l'archive est protégée par un mot de passe, ce bout de code s'execute mais le fichier ne se dezippe pas. Pouvez-vous m'aider?

2 réponses

cs_Julien39 Messages postés 6414 Date d'inscription mardi 8 mars 2005 Statut Modérateur Dernière intervention 29 juillet 2020 371
2 oct. 2012 à 11:28
Salut,

tu peux utilise l'option -ppassword pour dézipper ton fichier.
0
cs_Jack Messages postés 14006 Date d'inscription samedi 29 décembre 2001 Statut Modérateur Dernière intervention 28 août 2015 79
3 oct. 2012 à 16:34
Si c'est du VB.Net (catégorie), tes déclarations d'appels des APIs ne sont pas correctes (Long --> Integer).
Étonnant que cela fonctionne.

Vala
Jack, MVP VB
NB : Je ne répondrai pas aux messages privés

Le savoir est la seule matière qui s'accroit quand on la partage (Socrate)
0
Rejoignez-nous