Bonsoir Elementary et merci pour ces informations.
Bien que vos modifications soient probablement totalement fonctionnelles, j'ai actualisé l'UDF du premier message par les modifications ci-dessous :
Pour
_7ZipStartup()
:
Code : Tout sélectionner
Func _7ZipStartup()
If Not @Compiled Then ; If not compiled, test and open the right dll
If Not FileExists($sNoCompiledPath & $sZip32Dll) And _
Not FileExists($sNoCompiledPath & $sZip64Dll) Then Return SetError(2, 0, 0)
If @OSArch <> "X86" And @AutoItX64 = 1 Then
$hDLL_7ZIP = DllOpen($sNoCompiledPath & $sZip64Dll) ; Open x64 dll from no compiled path
Else
$hDLL_7ZIP = DllOpen($sNoCompiledPath & $sZip32Dll) ; Open x32 dll from no compiled path
EndIf
Else ; If compiled, test and open the right dll (that must be in ScriptDir for compiling)
If @OSArch <> "X86" And @AutoItX64 = 1 Then
If Not FileInstall("7-zip64.dll", $sCompiledPath & $sZip64Dll, 1) Then Return SetError(3, 0, 0)
$hDLL_7ZIP = DllOpen($sCompiledPath & $sZip64Dll) ; Open x64 dll from FileInstall path
Else
If Not FileInstall("7-zip32.dll", $sCompiledPath & $sZip32Dll, 1) Then Return SetError(3, 0, 0)
$hDLL_7ZIP = DllOpen($sCompiledPath & $sZip32Dll) ; Open x32 dll from FileInstall path
EndIf
EndIf
If $hDLL_7ZIP = -1 Then Return SetError(1, 0, 0) ; If no dll handle, return error
Return 1
EndFunc ;==>_7ZipStartup
Comme vous pouvez le constater, je teste l'environnement et la version d'AutoIt utilisée.
Cela limite l'utilisation de la DLL x64 dans un environnement x64 par un exe x64 ou par le lancement du script au3 ou a3x par la version x64 d'AutoIt.
Pour
_7ZipAdd()
j'ai pris en compte votre remarque bien qu'en théorie cet UDF a été créé à la base pour faire des archives 7Zip. Ceci dit comme il est possible d'utiliser les autres formats, pourquoi ne pas adapter ! J'ai aussi cherché (un peu) pour GZIP et BZIP2, sans succès. A première vue ce serait une commande différente, mais pas sur que dans les DLL jointe, le cryptage soit pris en charge.
Toujours pareil. Votre modification doit probablement fonctionner, mais je préfère celle-ci :
Func _7ZipAdd
($hWnd, $sArcName, $sFileName, $sHide = 0, $sCompress = 5, $sRecurse = 1, $sIncludeFile = 0, $sExcludeFile = 0, _
$sPassword = 0, $sSFX = 0, $sVolume = 0, $sWorkDir = 0) Local $iFlagDll = _7ZipControlStartup
() If $iFlagDll = 0 Then Return SetError(2, 0, 0) Local $HeaderEncode = " -mhe" If StringUpper(StringRight($sArcName, 3)) = "ZIP" Then $HeaderEncode = "" $sArcName = '"' & $sArcName & '"' $sFileName = '"' & $sFileName & '"' Local $iSwitch = "" If $sHide Then $iSwitch &= " -hide" $iSwitch &= " -mx" & $sCompress $iSwitch &= _RecursionSet
($sRecurse) If $sIncludeFile Then $iSwitch &= _IncludeFileSet
($sIncludeFile) If $sExcludeFile Then $iSwitch &= _ExcludeFileSet
($sExcludeFile) If $sPassword Then $iSwitch &= " -p" & $sPassword & $HeaderEncode If FileExists($sSFX) Then $iSwitch &= " -sfx" & $sSFX If $sVolume Then $iSwitch &= " -v" & $sVolume If $sWorkDir Then $iSwitch &= " -w" & $sWorkDir Local $tOutBuffer = DllStructCreate("char[32768]") Local $aRet = DllCall($hDLL_7ZIP, "int", "SevenZip", _
"hwnd", $hWnd, _
"str", "a " & $sArcName & " " & $sFileName & " " & $iSwitch, _
"ptr", DllStructGetPtr($tOutBuffer), _
"int", DllStructGetSize($tOutBuffer)) If $iFlagDll = 2 Then _7ZipShutdown
() If Not $aRet[0] Then Return SetError(0, 0, DllStructGetData($tOutBuffer, 1)) Return SetError(1, 0, 0)EndFunc ;==>_7ZipAdd
Concernant les DLL, il y a des liens dans l'UDF, mais je ne suis pas sur que ce soit encore d'actualité.
Celles disponibles sur le site 7Zip ne sont pas compatibles. Il faut ce contenter de celles qui sont fournies avec l'UDF.
Si vous voulez vraiment quelque chose d'autonome et de plus récent, je vous conseille 7Za.exe. Je ne met pas de lien direct, parce qu'en fonction de la version celui-ci ne serait plus bon.
Par contre sur
cette page, cliquez sur le lien à gauche de la ligne "7-Zip Extra: standalone console version, 7z DLL, Plugin for Far Manager" dans le tableau de la version que vous désirez. Il n'y aura plus de CallBack, mais c'est une bonne alternative. ^^