Twitter iPhone pliant OnePlus 11 PS5 Disney+ Orange Livebox Windows 11

extraire des fichiers zip?

12 réponses
Avatar
DP
Bonjour,

Je voudrais extraire des fichiers zip à partir de mon application VB6.
Shell("unzip.exe *.zip")
ne fonctionne pas.

Avez vous une idée?

Merci de votre aide

DP

10 réponses

1 2
Avatar
Houbahop
Bonjour,
Il est tout a fait possible d'extraire des zip avec shell et unzip.exe, mais
cela implique que :
- unzip.exe soit dans la wariable path de windows ou alors spécifie le
chemin de l'exe dans l'appel a shell, ou met l'exe dans le répertoire ou est
l'exe.
- connaitre la syntaxe d'unzip.exe. Je ne la connais pas, mais je ne suis
pas persuadé que : unzip.exe *.zip décompresse les fichier zip.
Il manque peut etre un ou des paramétres, mais je le répéte, je ne suis pas
sur de ça a 100%

Sinon il existe des composants ActiveX gratuits (me rapelle plus le nom)
ou la fameuse dll gratuite "infozip", qui permettent de zipper/dezipper
assez facilement.

Bonne chance.
Dominique

"DP" a écrit dans le message de news:

Bonjour,

Je voudrais extraire des fichiers zip à partir de mon application VB6.
Shell("unzip.exe *.zip")
ne fonctionne pas.

Avez vous une idée?

Merci de votre aide

DP




Avatar
DP
J'ai déjà essayé avec le chemin complet sans plus de résultat.
Un batch avec unzip *.zip fonctionne sans problème.
Je vais essayer de trouver cette fameuse dll.

Merci de votre aide

DP
Avatar
ng
Salut,

Regarde cet exemple : http://paris29.amen.fr/~ng/zip_vb.zip

--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/

DP wrote:
Bonjour,

Je voudrais extraire des fichiers zip à partir de mon application VB6.
Shell("unzip.exe *.zip")
ne fonctionne pas.

Avez vous une idée?

Merci de votre aide

DP


Avatar
Boss Hog
Salut, voila un code non optimiser qui fonctione avec PKZIPC(freeware)
je l'ai fait pour l'utiliser dans une dll depuis des pages ASP ou des lot
DTS(SQLserver)
à la création de l'instance dans la Sub "Class_Initialize()" on va lire le
path de PKZIPC dans la BDR
le reste est tres basic, mais tu doit pouvoir personnaliser à ta guise.....

Exemple d'utilisation depuis un lot DTS(VBScript):
Set oZip = CreateObject("MaClasse.PKZIP")
oZip.Command = "-extract"

'Set source
oZip.SourcePath = DTSGlobalVariables("HNCEPATH").Value
oZip.SourceFile = TMPname

'Set destination
oZip.DestPath = DTSGlobalVariables("HNCEPATH").Value & "tmp"

'Appel de la function de ZIP
Set oRes = oZip.Extract()
Set oZip = Nothing



La classe:
Const REG_SZ = 1 ' Unicode nul terminated string
Const REG_BINARY = 3 ' Free form binary
Const HKEY_CURRENT_USER = &H80000002
'********************************************************************
' PRIVATE METHODES
'********************************************************************
Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA"
(ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias
"RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal
lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long)
As Long

Private pkzipPath As String
Private PkzipFound As Boolean
Private mvarExecutedCommand As String 'local copy
'********************************************************************
' PROPERTIES
'********************************************************************
Private mvarSourceFile As String
Private mvarDestFile As String
Private mvarSourcePath As String
Private mvarDestPath As String
Private mvarCommand As String 'local copy
Private mvarPkzipPath As String 'local copy
Public Property Get PkzipAppPath() As String
PkzipAppPath = mvarPkzipPath
End Property
Public Property Let PkzipAppPath(ByVal newvalue As String)
mvarPkzipPath = newvalue
End Property
Public Property Get SourceFile() As String
SourceFile = mvarSourceFile
End Property
Public Property Let SourceFile(ByVal newvalue As String)
mvarSourceFile = newvalue
End Property

Public Property Get DestFile() As String
DestFile = mvarDestFile
End Property
Public Property Let DestFile(ByVal newvalue As String)
mvarDestFile = newvalue
End Property

Public Property Get SourcePath() As String
SourcePath = mvarSourcePath
End Property
Public Property Let SourcePath(ByVal newvalue As String)
mvarSourcePath = newvalue
End Property

Public Property Get DestPath() As String
DestPath = mvarDestPath
End Property
Public Property Let DestPath(ByVal newvalue As String)
mvarDestPath = newvalue
End Property
Public Property Let Command(ByVal vData As String)
mvarCommand = vData
End Property
Public Property Get Command() As String
Command = mvarCommand
End Property

Public Property Get ExecutedCommand() As String
ExecutedCommand = mvarExecutedCommand
End Property

'********************************************************************
' METHODES
'********************************************************************
Private Sub Class_Initialize()
Dim oFso As FileSystemObject, pkShortPass As String
PkzipFound = True
pkzipPath = GetPkPath()
If pkzipPath <> "" Then
Set oFso = New FileSystemObject
PkzipAppPath = pkzipPath
pkShortPass = CheckPath(oFso.GetFolder(pkzipPath).ShortPath)
pkzipPath = pkShortPass
Set oFso = Nothing
End If
Set oError = New MWerrorManager
End Sub

Private Function GetPkPath() As String
'Get a string from the registry
GetPkPath = GetString(HKEY_CURRENT_USER,
"SOFTWAREMicrosoftWindowsCurrentVersionApp Pathspkzipc.exe", "Path")
If GetPkPath = "" Then PkzipFound = False
End Function
Private Function GetString(hKey As Long, strPath As String, strValue As
String)
Dim Ret
'Open the key
RegOpenKey hKey, strPath, Ret
'Get the key's content
GetString = RegQueryStringValue(Ret, strValue)
'Close the key
RegCloseKey Ret
End Function
Private Function RegQueryStringValue(ByVal hKey As Long, ByVal strValueName
As String) As String
Dim lResult As Long, lValueType As Long, strBuf As String, lDataBufSize As
Long
'retrieve nformation of the key
lResult = RegQueryValueEx(hKey, strValueName, 0, lValueType, ByVal 0,
lDataBufSize)
If lResult = 0 Then
If lValueType = REG_SZ Then
'Create a buffer
strBuf = String(lDataBufSize, Chr$(0))
'retrieve the keys content
lResult = RegQueryValueEx(hKey, strValueName, 0, 0, ByVal strBuf,
lDataBufSize)
If lResult = 0 Then
'Remove the unnecessary chr$(0)
RegQueryStringValue = Left$(strBuf, InStr(1, strBuf, Chr$(0)) - 1)
End If
ElseIf lValueType = REG_BINARY Then
Dim strData As Integer
'retrieve the keys value
lResult = RegQueryValueEx(hKey, strValueName, 0, 0, strData, lDataBufSize)
If lResult = 0 Then
RegQueryStringValue = strData
End If
End If
End If
End Function
Private Function CheckPath(path) As String
'Check du chemin physique
If Right(path, 1) <> "" Then
CheckPath = path & ""
Else
CheckPath = path
End If
End Function
Public Function MakeZip() As Boolean
Dim oFso As FileSystemObject
Dim ShortSrc As String, ShortDest As String, tmpValue As String
Dim Sl As Variant, CmdLine As String
MakeZip = True
'check for properties filled
Set oFso = New FileSystemObject
If Not oFso.FolderExists(SourcePath) Then
MakeZip = False
Exit Function
End If
If Not oFso.FileExists(CheckPath(SourcePath) & SourceFile) Then
MakeZip = False
Exit Function
End If
If Not oFso.FolderExists(DestPath) Then
MakeZip = False
Exit Function
End If

If Command = "" Then
MakeZip = False
Exit Function
End If
If Not PkzipFound Then
MakeZip = False
Exit Function
End If

'Get the short name of folder and file existing
tmpValue = oFso.GetFolder(SourcePath).ShortPath
ShortSrc = CheckPath(tmpValue)
tmpValue = oFso.GetFile(ShortSrc & SourceFile).ShortName
ShortSrc = ShortSrc & tmpValue


tmpValue = oFso.GetFolder(DestPath).ShortPath
ShortDest = CheckPath(tmpValue)
ShortDest = ShortDest & DestFile

'Set the command line
mvarExecutedCommand = pkzipPath & "pkzipc " & Command & " """ & ShortDest &
""" """ & ShortSrc & """"
CmdLine = mvarExecutedCommand
On Error Resume Next
Sl = shell(CmdLine, vbHide)
If Err.Number <> 0 Then
MakeZip = False
Else
MakeZip = True
End If
Set oFso = Nothing
End Function
Public Function Extract() As Boolean
Dim oFso As FileSystemObject
Dim ShortSrc As String, ShortDest As String, tmpValue As String
Dim Sl As Variant, CmdLine As String
Extract = True
'check for properties filled
Set oFso = New FileSystemObject
If Not oFso.FolderExists(SourcePath) Then
Extract = False
Exit Function
End If
If Not oFso.FileExists(CheckPath(SourcePath) & SourceFile) Then
Extract = False
Exit Function
End If
If Not oFso.FolderExists(DestPath) Then
Extract = False
Exit Function
End If
If Command = "" Then
Extract = False
Exit Function
End If
If Not PkzipFound Then
Extract = False
Exit Function
End If

'Get the short name of folder and file existing
tmpValue = oFso.GetFolder(SourcePath).ShortPath
ShortSrc = CheckPath(tmpValue)
tmpValue = oFso.GetFile(ShortSrc & SourceFile).ShortName
ShortSrc = ShortSrc & tmpValue


tmpValue = oFso.GetFolder(DestPath).ShortPath
ShortDest = CheckPath(tmpValue)
ShortDest = ShortDest

'Set the command line
mvarExecutedCommand = pkzipPath & "pkzipc " & Command & " """ & ShortSrc &
""" """ & ShortDest & """"
CmdLine = mvarExecutedCommand
On Error Resume Next
Sl = shell(CmdLine, vbHide)
If Err.Number <> 0 Then
Extract = False
Else
Extract = True
End If
Set oFso = Nothing
End Function



@+ Boss Hog

"DP" wrote in message
news:
Bonjour,

Je voudrais extraire des fichiers zip à partir de mon application VB6.
Shell("unzip.exe *.zip")
ne fonctionne pas.

Avez vous une idée?

Merci de votre aide

DP




Avatar
françois
personellement j'utilise la dll Sawzip qui fonctionne
sans problème dans un sens comme dans l'autre. Tu la
trouveras sans difficulté avec n'importe quel moteur de
recherche
fonctionne sous win98 et Xp
françois
Avatar
Gloops
Bonjour,

Si je ne m'abuse, ta syntaxe n'est pas correcte, il faut taper
Shell "unzip.exe", "*.zip"

à savoir un argument pour le chemin du programme, et un pour la ligne de
commandes (les arguments) à lui passer.

Enfin vérifie dans l'aide de Shell, comme tu as déjà quatre réponses
sans que personne n'ait tiqué, ça me donne un doute.
_________________________________
DP a écrit, le 26/10/2004 21:43 :

Bonjour,

Je voudrais extraire des fichiers zip à partir de mon application VB6.
Shell("unzip.exe *.zip")
ne fonctionne pas.

Avez vous une idée?

Merci de votre aide

DP




Avatar
Gloops
Il y a une question au sujet des parenthèses, aussi.
En VB.Net c'est bon, en VB soit tu passes à valeur à une variable,
ret = Shell("unzip.exe", "*.zip")

soit tu ne mets pas de parenthèses
Shell "unzip.exe", "*.zip"

Sinon tu te fais jeter.

P.S. à toi de vérifier la question de la licence pour unzip ...
_____________________________________
Gloops a écrit, le 27/10/2004 17:29 :

Bonjour,

Si je ne m'abuse, ta syntaxe n'est pas correcte, il faut taper
Shell "unzip.exe", "*.zip"

à savoir un argument pour le chemin du programme, et un pour la ligne de
commandes (les arguments) à lui passer.

Enfin vérifie dans l'aide de Shell, comme tu as déjà quatre réponses
sans que personne n'ait tiqué, ça me donne un doute.
_________________________________
DP a écrit, le 26/10/2004 21:43 :

Bonjour,

Je voudrais extraire des fichiers zip à partir de mon application VB6.
Shell("unzip.exe *.zip")
ne fonctionne pas.

Avez vous une idée?

Merci de votre aide

DP







Avatar
ng
Salut,

...ou soi tu utilises call :

Call Shell("unzip.exe *.zip") '// le 2ème paramètre ne concerne pas les
paramètres avec shell.

--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/

Gloops wrote:
Il y a une question au sujet des parenthèses, aussi.
En VB.Net c'est bon, en VB soit tu passes à valeur à une variable,
ret = Shell("unzip.exe", "*.zip")

soit tu ne mets pas de parenthèses
Shell "unzip.exe", "*.zip"

Sinon tu te fais jeter.

P.S. à toi de vérifier la question de la licence pour unzip ...
_____________________________________
Gloops a écrit, le 27/10/2004 17:29 :

Bonjour,

Si je ne m'abuse, ta syntaxe n'est pas correcte, il faut taper
Shell "unzip.exe", "*.zip"

à savoir un argument pour le chemin du programme, et un pour la
ligne de commandes (les arguments) à lui passer.

Enfin vérifie dans l'aide de Shell, comme tu as déjà quatre réponses
sans que personne n'ait tiqué, ça me donne un doute.
_________________________________
DP a écrit, le 26/10/2004 21:43 :

Bonjour,

Je voudrais extraire des fichiers zip à partir de mon application
VB6. Shell("unzip.exe *.zip")
ne fonctionne pas.

Avez vous une idée?

Merci de votre aide

DP






Avatar
DP
Je suis allé voir sur Google et sawzip.dll est souvent indiquée comme étant
un spyware.

Canular?

DP
Avatar
DP
Merci beaucoup.

Ça fonctionne parfaitement avec Call Shell("unzip.exe *.zip")
1 2