Cherchant à désarchiver des fichiers ZIP (Comme vous l’avez surement déjà vu


Il faut forcement avoir 7-zip32.dll pour que cela fonctionne. le source est l'archive est sur http://www.koakdesign.info/news/?url=4d&val=32
Code : Tout sélectionner
EnableExplicit
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
;{ - CONSTANTE
#FNAME_MAX32 = 513
;}
;{ - STRUCTURE
Structure tagINDIVIDUALINFO
dwOriginalSize.l
dwCompressedSize.l
dwCRC.l
uFlag.l
uOSType.l
wRatio.w
wDate.w
wTime.w
szFileName.s{#FNAME_MAX32}
dummy1.s{3}
szAttribute.s{8}
szMode.s{8}
EndStructure
;}
;{ - GLOBAL
Global openlibrary_7zip.l
;}
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
Procedure.b setUnCompressZIP(filename.s, filedest.s, hWnd.l)
;
Protected lresult.l
Protected sresult.s
If openlibrary_7zip <> 0
If CallFunction(openlibrary_7zip, "SevenZipCheckArchive", @filename.s, 1) <> 0
sresult = "x -y "+ Chr(34) + filename + Chr(34) + " " + Chr(34) + filedest + Chr(34) + " *"
lresult = CallFunction(openlibrary_7zip, "SevenZip", hWnd, @sresult, @"", 0)
If lresult = 0
lresult = CallFunction(openlibrary_7zip, "SevenZipCloseArchive", lresult)
ProcedureReturn #True
EndIf
lresult = CallFunction(openlibrary_7zip, "SevenZipCloseArchive", lresult)
EndIf
EndIf
EndProcedure
Procedure.b Uncompress_7zip(filename.s, filedest.s, hWnd.l)
;
Protected i.l
Protected lresult.l
Protected udt7ZINDIVIDUALINFO.tagINDIVIDUALINFO
ClearGadgetItems(2)
openlibrary_7zip = OpenLibrary(#PB_Any,"7-zip32.dll")
If openlibrary_7zip <> 0
If CallFunction(openlibrary_7zip, "SevenZipCheckArchive", @filename, 1) <> 0
If CallFunction(openlibrary_7zip, "SevenZipGetRunning") = 0
lresult = CallFunction(openlibrary_7zip, "SevenZipSetBackGroundMode", 0)
lresult = CallFunction(openlibrary_7zip, "SevenZipSetCursorMode", 0)
lresult = CallFunction(openlibrary_7zip, "SevenZipOpenArchive", hWnd, @filename, 0)
If lresult <> 0
If CallFunction(openlibrary_7zip, "SevenZipFindFirst", lresult, @"*", udt7ZINDIVIDUALINFO) = 0
Repeat
i + 1
AddGadgetItem(2, -1, udt7ZINDIVIDUALINFO\szFileName)
Until CallFunction(openlibrary_7zip, "SevenZipFindNext", lresult, udt7ZINDIVIDUALINFO) <> 0
CallFunction(openlibrary_7zip, "SevenZipCloseArchive", lresult)
setUnCompressZIP(filename, filedest, hWnd)
EndIf
EndIf
Else
Debug "Erreur: 7-Zip32.dll est déjà en cours d'execution"
EndIf
EndIf
CloseLibrary(openlibrary_7zip)
openlibrary_7zip = 0
EndIf
EndProcedure
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; ****************************************************************************
; +--------------------------------------------------------------------------+
; | |
; +--------------------------------------------------------------------------+
; - ROUTINE DE TEST.
Define hWnd.l
Define event.l
hWnd = OpenWindow(0, 0, 0, 640, 500, "Zip Extractor", #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget | #PB_Window_ScreenCentered)
If hWnd <> 0
ButtonGadget(0, 10, 10, 100, 20, "Chargement ZIP")
ListViewGadget(2,10,40,400,250)
Repeat
event = WaitWindowEvent(50)
If event = #PB_Event_Gadget :
If EventGadget() = 0
Uncompress_7zip(OpenFileRequester("Ouvrir un archive zip", "", "Archive Zip|*.zip", 0), "temps\", hWnd)
EndIf
EndIf
Until event = #PB_Event_CloseWindow
EndIf
GallyHC