Hallo zusammen,
ich möchte mit 7zip "tar" und "tgz" Archive erstellen und bin dabei auf folgenden Thread gestoßen:
https://www.autoitscript.com/f…/25984-7-zip32dll/page/4/
Leider laufe ich immer auf Fehler 33026 (Rückgabewert im DLLCall) und weiß aktuell nicht woran das liegen könnte. @error ist jedoch "0".
AutoIt: SevenZip.au3
Opt('MustDeclareVars', 1)
#cs
------------------------------------------
Functions for use with 7-zip32.dll
Version 0.4.5 Updated by Tlem
Copyright (C) 2006 JAK-Software.org. Released under GNU LGPL.
Please Note: To use the functions, the 7-zip32.dll file must be in the scriptDir
or you must set the path where 7-zip32.dll is installed.
Switch that can be used in functions (by $CMD):
-p(password) exemple : -pMyPassword
-v{Size}[b | k | m | g] exemple : -v1400k
-sfx (SFX archive - ask for title and other)
-y For assume Yes on all queries (for extract function).
Changes:
0.4.5: - Updated By Tlem
- Fixed error in function code (DllCall).
Correction made in accordance of the 7-Zip32 API :
int WINAPI SevenZip(const HWND _hwnd, LPCSTR _szCmdLine, LPSTR _szOutput, const DWORD _dwSize)
- Add a _SevenZipUpDate() function.
- Add an extra parameters for _SevenZipAdd() and _SevenZipUpDate() functions to set recursive or not.
- Add a strip leading/trailing white space of $CMD.
0.4.4: - Updated By Tlem
- Fixed error in code of return
0.4.3: - Updated By Tlem
- Fixed error on DllCall parameters.
- Fixed Relative path of files and Dll doesn't work.
- Added control if 7-zip32.dll can be find.
0.4.2: - Updated By Tlem
- Updated to work with AutoIt 3.2.12.0
- Made correction for use full path of files.
- Added parameter to indicate the path of 7-zip32.dll (ScriptDir by default).
- Deleted Hwnd Argument
0.4.1: - Replaced last parameter: "str", 0 ==> "int", 0
0.4: - Added Hwnd Argument
- Modified Variable Names
- Added SetError(1) and Return 0 for Errors
0.3: - Removed @ScriptDir in DllOpen
------------------------------------------
#ce
Global $ret
;===============================================================================
;
; Description: Adds Files to an Archive/Creates an Archive
; Parameter(s): $Dll - The path of 7-zip32.dll (ScriptDir by default)
; $sArchive - The Archive to use
; $sOutDir - Where to extract the files
; $sFilter - Files to extract from the Archive (e.g. *.exe)
; $sCMDLine - Optional Options
; Requirement(s): None
; Return Value(s): On Success - Return 1
; On Failure - Return 0
; Author(s): JAK-Software.org (Updated By Tlem)
; Note(s): http://www.7-zip.org/download.html for switch option and cmdline help
;
;===============================================================================
Func _SevenZipAdd($Dll, $sArchive, $sFiles, $sRecurse = 0, $iLevel = 6, $sType = "7z", $sCMDLine = "")
If $Dll = "" Then $Dll = "7-zip32.dll"
If Not FileExists($Dll) Then Return 0
If $sRecurse = 0 Then
$sRecurse = ""
Else
$sRecurse = "-r"
EndIf
$sCMDLine = StringStripWS($sCMDLine, 3)
$Dll = DllOpen($Dll)
$Ret = DllCall($Dll, "int", "SevenZip", "hwnd", 0, "str",'a ' & $sCMDLine & ' -mx=' & $iLevel & ' -t' & $sType & ' "' & $sArchive & '" "' & $sFiles & '" ' & $sRecurse, "str", "", "int", 65535) ;hier kommt der Fehler beim Ausführen, Rückgabewert der Funktion: 33026, @error ist jedoch 0
DllClose($Dll)
If Not @error Then
If $Ret[0] <> 0 Then
Return (3 & $Ret[0])
Else
Return 1
EndIf
Else
Return 0
EndIf
EndFunc ;==>_SevenZipAdd
;===============================================================================
;
; Description: Update Files to an Archive/Creates an Archive
; Parameter(s): $Dll - The path of 7-zip32.dll (ScriptDir by default)
; $sArchive - The Archive to use
; $sOutDir - Where to extract the files
; $sFilter - Files to extract from the Archive (e.g. *.exe)
; $sCMDLine - Optional Options
; Requirement(s): None
; Return Value(s): On Success - Return 1
; On Failure - Return 0
; Author(s): JAK-Software.org (Updated By Tlem)
; Note(s): http://www.7-zip.org/download.html for switch option and cmdline help
;
;===============================================================================
Func _SevenZipUpDate($Dll, $sArchive, $sFiles, $sRecurse = 0, $iLevel = 6, $sType = "7z", $sCMDLine = "")
If $Dll = "" Then $Dll = "7-zip32.dll"
If Not FileExists($Dll) Then Return 2
If $sRecurse = 0 Then
$sRecurse = ""
Else
$sRecurse = "-r"
EndIf
$sCMDLine = StringStripWS($sCMDLine, 3)
$Dll = DllOpen($Dll)
$Ret = DllCall($Dll, "int", "SevenZip", "hwnd", 0, "str", 'u ' & $sCMDLine & ' -mx=' & $iLevel & ' -t' & $sType & ' "' & $sArchive & '" "' & $sFiles & '" ' & $sRecurse, "str", "", "int", 65535)
DllClose($Dll)
If Not @error Then
If $Ret[0] <> 0 Then
Return (3 & $Ret[0])
Else
Return 1
EndIf
Else
Return 0
EndIf
EndFunc ;==>_SevenZipUpDate
;===============================================================================
;
; Description: Extracts files from an archive with full path
; Parameter(s): $Dll - The path of 7-zip32.dll (ScriptDir by default)
; $sArchive - The Archive to use
; $sOutDir - Where to extract the files
; $sFilter - Files to extract from the Archive (e.g. *.exe)
; $sCMDLine - Optional Options
; Requirement(s): None
; Return Value(s): On Success - Return 1
; On Failure - Return 0
; Author(s): JAK-Software.org (Updated By Tlem)
; Note(s): http://www.7-zip.org/download.html for switch option and cmdline help
;
;===============================================================================
Func _SevenZipExtract($Dll, $sArchive, $sOutDir = ".", $sFilter = '*', $sCMDLine = '')
If $Dll = "" Then $Dll = "7-zip32.dll"
If Not FileExists($Dll) Then Return 2
$Dll = DllOpen($Dll)
$Ret = DllCall($Dll, "int", "SevenZip", "hwnd", 0, "str", 'x ' & $sCMDLine & ' -o"' & $sOutDir & '" "' & $sArchive & '" ' & $sFilter, "str", "", "int", 65535)
$sCMDLine = StringStripWS($sCMDLine, 3)
DllClose($Dll)
If Not @error Then
If $Ret[0] <> 0 Then
Return (3 & $Ret[0])
Else
Return 1
EndIf
Else
Return 0
EndIf
EndFunc ;==>_SevenZipExtract
;===============================================================================
;
; Description: Executes 7-zip Commands (Syntax Like in 7z.exe/7za.exe)
; Parameter(s): $Dll - The path of 7-zip32.dll (ScriptDir by default)
; $sCMDLine - The Commandline
; Requirement(s): None
; Return Value(s): On Success - Return 1
; On Failure - Return 0
; Author(s): JAK-Software.org (Updated By Tlem)
; Note(s): http://www.7-zip.org/download.html for switch option and cmdline help
;
;===============================================================================
Func _SevenZipCMD($Dll, $sCMDLine)
If $Dll = "" Then $Dll = "7-zip32.dll"
If Not FileExists($Dll) Then Return 2
$sCMDLine = StringStripWS($sCMDLine, 3)
$Dll = DllOpen($Dll)
$Ret = DllCall($Dll, "int", "SevenZip", "hwnd", 0, "str", '"' & $sCMDLine & '"', "str", "", "int", 65535)
DllClose($Dll)
If Not @error Then
If $Ret[0] <> 0 Then
Return (3 & $Ret[0])
Else
Return 1
EndIf
Else
Return 0
EndIf
EndFunc ;==>_SevenZipCMD
Alles anzeigen
AutoIt: Das Programm
Opt('MustDeclareVars', 1)
#include <SevenZip.au3>
#include <Constants.au3>
#include <WindowsConstants.au3>
#include <StaticConstants.au3>
#include <Date.au3>
#include <File.au3>
#include <Array.au3>
#include <WinAPI.au3>
;~ Global $tTime, $aTime, $logname, $File
Global $Eingabe, $IP, $Gerät
While 1
$Eingabe= InputBox('Wert1', 'Wert1', '', '', 10)
If StringLen($Eingabe) = Then
$Gerät = InputBox('Gerät', 'Gerätenummer (1-4)', '1', '', 10)
if $Gerät <> '' Then
Doit()
EndIf
Else
Exit
EndIf
WEnd
Func Doit()
;
; -Hier wird eine IP erzeugt
;
lan()
wifi()
;Ordner settings.local als Archiv erstellen
$Return = _SevenZipAdd("", @ScriptDir & '\settings.local.tar', @ScriptDir & '\settings.local\', 1, 9, "tar", "-hide")
if $Return <> 1 then MsgBox(1, 'Fehler', 'Fehler beim erstellen des Archivs: ' & $Return) ;333026 -> 33026
$Return = _SevenZipAdd("", @ScriptDir & '\settings.local.tgz', @ScriptDir & '\settings.local.tar', 1, 9, "tgz", "-hide")
if $Return <> 1 then MsgBox(1, 'Fehler', 'Fehler beim erstellen des Archivs: ' & $Return) ;333026 -> 33026
Exit
EndFunc
Func wifi()
;Hier wird eine Datei modifiziert
EndFunc
Func lan()
;Hier wird eine Datei modifiziert
EndFunc
Alles anzeigen