📄 7zip.au3
字号:
; #VARIABLES# ===================================================================================================================
Global $hDLL_7ZIP = DllOpen(@ScriptDir & "\7-zip32.dll")
If $hDLL_7ZIP = -1 Then Exit 1
Global Const $FNAME_MAX32 = 512
Global $hArchiveProc
;File attributes constants
Global Const $FA_RDONLY = 0x01 ;Reading private file
Global Const $FA_HIDDEN = 0x02 ;Invisibility attribute file
Global Const $FA_SYSTEM = 0x04 ;System file
Global Const $FA_LABEL = 0x08 ;Volume label
Global Const $FA_DIREC = 0x10 ;Directory
Global Const $FA_ARCH = 0x20 ;Retention bit
Global Const $FA_ENCRYPTED = 0x40 ;The password the file which is protected
; ===============================================================================================================================
; #STRUCTURES# ==================================================================================================================
Global $tagINDIVIDUALINFO = "int dwOriginalSize;int dwCompressedSize;int dwCRC;uint uFlag;uint uOSType;short wRatio;" & _
"short wDate;short wTime;char szFileName[" & $FNAME_MAX32 + 1 & "];char dummy1[3];" & _
"char szAttribute[8];char szMode[8]"
Global Const $tagEXTRACTINGINFO = "int dwFileSize;int dwWriteSize;char szSourceFileName[" & $FNAME_MAX32 + 1 & "];" & _
"char dummy1[3];char szDestFileName[" & $FNAME_MAX32 + 1 & "];char dummy[3]"
Global Const $tagEXTRACTINGINFOEX = $tagEXTRACTINGINFO & ";dword dwCompressedSize;dword dwCRC;uint uOSType;short wRatio;" & _
"short wDate;short wTime;char szAttribute[8];char szMode[8]"
; ===============================================================================================================================
; #FUNCTION# ====================================================================================================================
; Name...........: _7ZipAdd
; Description ...: Adds files to archive
; Syntax.........: _7ZipAdd($hWnd, $sArcName, $sFileName[, $sHide = 0[, $sCompress = 5[, $sRecurse = 1[, $sIncludeFile = 0[, _
; $sExcludeFile = 0[, $sPassword = 0[, $sSFX = 0[, $sVolume = 0[, $sWorkDir = 0]]]]]]]]])
; Parameters ....: $hWnd - Handle to parent or owner window
; $sArcName - Archive file name
; $sFileName - File names to archive up
; $sHide - Use this switch if you want the CallBack function to be called
; $sCompress - Compress level 0-9
; $sRecurse - Recursion method: 0 - Disable recursion
; 1 - Enable recursion
; 2 - Enable recursion only for wildcard names
; $sIncludeFile - Include filenames, specifies filenames and wildcards or list file that specify processed files
; $sExcludeFile - Exclude filenames, specifies what filenames or (and) wildcards must be excluded from operation
; $sPassword - Specifies password
; $sSFX - Creates self extracting archive
; $sVolume - Specifies volumes sizes
; $sWorkDir - Sets working directory for temporary base archive
; Return values .: Success - Returns the string with results
; Failure - Returns 0 and and sets the @error flag to 1
; Author ........: R. Gilman (rasim)
; ===============================================================================================================================
Func _7ZipAdd($hWnd, $sArcName, $sFileName, $sHide = 0, $sCompress = 5, $sRecurse = 1, $sIncludeFile = 0, $sExcludeFile = 0, _
$sPassword = 0, $sSFX = 0, $sVolume = 0, $sWorkDir = 0)
$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
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 Not $aRet[0] Then Return SetError(0, 0, DllStructGetData($tOutBuffer, 1))
Return SetError(1, 0, 0)
EndFunc ;==>_7ZipAdd
; #FUNCTION# ====================================================================================================================
; Name...........: _7ZipDelete
; Description ...: Deletes files from archive
; Syntax.........: _7ZipDelete($hWnd, $sArcName, $sFileName[, $sHide = 0[, $sCompress = 5[, $sRecurse = 1[, $sIncludeFile = 0[, _
; $sExcludeFile = 0[, $sPassword = 0[, $sWorkDir = 0]]]]]]])
; Parameters ....: $hWnd - Handle to parent or owner window
; $sArcName - Archive file name
; $sFileName - File names to deleting
; $sHide - Use this switch if you want the CallBack function to be called
; $sCompress - Compress level 0-9
; $sRecurse - Recursion method: 0 - Disable recursion
; 1 - Enable recursion
; 2 - Enable recursion only for wildcard names
; $sIncludeFile - Include filenames, specifies filenames and wildcards or list file that specify processed files
; $sExcludeFile - Exclude filenames, specifies what filenames or (and) wildcards must be excluded from operation
; $sPassword - Specifies password
; $sWorkDir - Sets working directory for temporary base archive
; Return values .: Success - Returns the string with results
; Failure - Returns 0 and and sets the @error flag to 1
; Author ........: R. Gilman (rasim)
; ===============================================================================================================================
Func _7ZipDelete($hWnd, $sArcName, $sFileName, $sHide = 0, $sCompress = 5, $sRecurse = 1, $sIncludeFile = 0, $sExcludeFile = 0, _
$sPassword = 0, $sWorkDir = 0)
$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
If $sWorkDir Then $iSwitch &= " -w" & $sWorkDir
Local $tOutBuffer = DllStructCreate("char[32768]")
Local $aRet = DllCall($hDLL_7ZIP, "int", "SevenZip", _
"hwnd", $hWnd, _
"str", "d " & $sArcName & " " & $sFileName & " " & $iSwitch, _
"ptr", DllStructGetPtr($tOutBuffer), _
"int", DllStructGetSize($tOutBuffer))
If Not $aRet[0] Then Return SetError(0, 0, DllStructGetData($tOutBuffer, 1))
Return SetError(1, 0, 0)
EndFunc ;==>_7ZipDelete
; #FUNCTION# ====================================================================================================================
; Name...........: _7ZIPExtract
; Description ...: Extracts files from archive to the current directory or to the output directory
; Syntax.........: _7ZIPExtract($hWnd, $sArcName[, $sOutput = 0[, $sHide = 0[, $sOverwrite = 0[, $sRecurse = 1[, _
; $sIncludeArc[, $sExcludeArc[, $sIncludeFile = 0[, $sExcludeFile = 0[, $sPassword = 0[, _
; $sYes = 0]]]]]]]]]])
; Parameters ....: $hWnd - Handle to parent or owner window
; $sArcName - Archive file name
; $sOutput - Output directory
; $sHide - Use this switch if you want the CallBack function to be called
; $sOverwrite - Overwrite mode: 0 - Overwrite All existing files without prompt, _
; 1 - Skip extracting of existing files, _
; 2 - Auto rename extracting file, _
; 3 - auto rename existing file
; $sRecurse - Recursion method: 0 - Disable recursion
; 1 - Enable recursion
; 2 - Enable recursion only for wildcard names
; $sIncludeArc - Include archive filenames
; $sExcludeArc - Exclude archive filenames
; $sIncludeFile - Include filenames, specifies filenames and wildcards or list file that specify processed files
; $sExcludeFile - Exclude filenames, specifies what filenames or (and) wildcards must be excluded from operation
; $sPassword - Specifies password
; $Yes - assume Yes on all queries
; Return values .: Success - Returns the string with results
; Failure - Returns 0 and and sets the @error flag to 1
; Author ........: R. Gilman (rasim)
; ===============================================================================================================================
Func _7ZIPExtract($hWnd, $sArcName, $sOutput = 0, $sHide = 0, $sOverwrite = 0, $sRecurse = 1, $sIncludeArc = 0, $sExcludeArc = 0, _
$sIncludeFile = 0, $sExcludeFile = 0, $sPassword = 0, $sYes = 0)
$sArcName = '"' & $sArcName & '"'
Local $iSwitch = ""
If $sOutput Then $iSwitch = ' -o"' & $sOutput & '"'
If $sHide Then $iSwitch &= " -hide"
$iSwitch &= _OverwriteSet($sOverwrite)
$iSwitch &= _RecursionSet($sRecurse)
If $sIncludeArc Then $iSwitch &= _IncludeArcSet($sIncludeArc)
If $sExcludeArc Then $iSwitch &= _ExcludeArcSet($sExcludeArc)
If $sIncludeFile Then $iSwitch &= _IncludeFileSet($sIncludeFile)
If $sExcludeFile Then $iSwitch &= _ExcludeFileSet($sExcludeFile)
If $sPassword Then $iSwitch &= " -p" & $sPassword
If $sYes Then $iSwitch &= " -y"
Local $tOutBuffer = DllStructCreate("char[32768]")
Local $aRet = DllCall($hDLL_7ZIP, "int", "SevenZip", _
"hwnd", $hWnd, _
"str", "e " & $sArcName & " " & $iSwitch, _
"ptr", DllStructGetPtr($tOutBuffer), _
"int", DllStructGetSize($tOutBuffer))
If Not $aRet[0] Then Return SetError(0, 0, DllStructGetData($tOutBuffer, 1))
Return SetError(1, 0, 0)
EndFunc ;==>_7ZIPExtract
; #FUNCTION# ====================================================================================================================
; Name...........: _7ZIPExtractEx
; Description ...: Extracts files from archive with full paths to the current directory or to the output directory
; Syntax.........: _7ZIPExtract($hWnd, $sArcName[, $sOutput = 0[, $sHide = 0[, $sOverwrite = 0[, $sRecurse = 1[, _
; $sIncludeArc[, $sExcludeArc[, $sIncludeFile = 0[, $sExcludeFile = 0[, $sPassword = 0[, _
; $sYes = 0]]]]]]]]]])
; Parameters ....: $hWnd - Handle to parent or owner window
; $sArcName - Archive file name
; $sOutput - Output directory
; $sHide - Use this switch if you want the CallBack function to be called
; $sOverwrite - Overwrite mode: 0 - Overwrite All existing files without prompt, _
; 1 - Skip extracting of existing files, _
; 2 - Auto rename extracting file, _
; 3 - auto rename existing file
; $sRecurse - Recursion method: 0 - Disable recursion
; 1 - Enable recursion
; 2 - Enable recursion only for wildcard names
; $sIncludeArc - Include archive filenames
; $sExcludeArc - Exclude archive filenames
; $sIncludeFile - Include filenames, specifies filenames and wildcards or list file that specify processed files
; $sExcludeFile - Exclude filenames, specifies what filenames or (and) wildcards must be excluded from operation
; $sPassword - Specifies password
; $Yes - assume Yes on all queries
; Return values .: Success - Returns the string with results
; Failure - Returns 0 and and sets the @error flag to 1
; Author ........: R. Gilman (rasim)
; ===============================================================================================================================
Func _7ZipExtractEx($hWnd, $sArcName, $sOutput = 0, $sHide = 0, $sOverwrite = 0, $sRecurse = 1, $sIncludeArc = 0, _
$sExcludeArc = 0, $sIncludeFile = 0, $sExcludeFile = 0, $sPassword = 0, $sYes = 0)
$sArcName = '"' & $sArcName & '"'
Local $iSwitch = ""
If $sOutput Then $iSwitch = ' -o"' & $sOutput & '"'
If $sHide Then $iSwitch &= " -hide"
$iSwitch &= _OverwriteSet($sOverwrite)
$iSwitch &= _RecursionSet($sRecurse)
If $sIncludeArc Then $iSwitch &= _IncludeArcSet($sIncludeArc)
If $sExcludeArc Then $iSwitch &= _ExcludeArcSet($sExcludeArc)
If $sIncludeFile Then $iSwitch &= _IncludeFileSet($sIncludeFile)
If $sExcludeFile Then $iSwitch &= _ExcludeFileSet($sExcludeFile)
If $sPassword Then $iSwitch &= " -p" & $sPassword
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -