#include <7ZipM.au3>
Global $endex, $flc, $tp
Global $Form1 = GUICreate("Form1", 566, 151, 636, 197)
Global $Progress1 = GUICtrlCreateProgress(64, 56, 438, 17)
Local $Button1 = GUICtrlCreateButton("Старт", 80, 104, 75, 25)
Global $Button2 = GUICtrlCreateButton("Стоп", 440, 104, 75, 25)
GUISetState()
While 1
If $endex Then
GUICtrlSetData($Progress1, '')
GUIRegisterMsg(0x0111, '')
_7ZipShutdown()
$endex = 0
EndIf
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Button1
GUIRegisterMsg(0x0111, 'WM_COMMAND')
_7ZipStartup()
_7ZipSetOwnerWindowEx($Form1, "_ARCHIVERPROC")
_7ZIPExtractEx($Form1, _ANSIToOEM(@ScriptDir & '\test.7z'), _ANSIToOEM(@ScriptDir & '\testdir'), 1)
_7ZipKillOwnerWindowEx($Form1)
_7ZipShutdown()
GUICtrlSetData($Progress1, '')
GUIRegisterMsg(0x0111, '')
Case $Button2
EndSwitch
WEnd
Func _ARCHIVERPROC($hWnd, $Msg, $nState, $ExInfo)
Local $iFileSize, $iWriteSize, $iPercent = 0
If $flc Then
_7ZipKillOwnerWindowEx($Form1)
$endex = 1
$flc = 0
Return
EndIf
If $nState = 0 Then; 0 или 1 если в архиве несколько файлов, 1 - если в архиве один файл
Local $EXTRACTINGINFO = DllStructCreate($tagEXTRACTINGINFO, $ExInfo)
$iFileSize = DllStructGetData($EXTRACTINGINFO, "dwFileSize")
$iWriteSize = DllStructGetData($EXTRACTINGINFO, "dwWriteSize")
$iPercent = Floor($iWriteSize / $iFileSize * 100)
GUICtrlSetData($Progress1, $iPercent)
Return 1
EndIf
If $nState = 2 Then GUICtrlSetData($Progress1, 100)
Return 1
EndFunc ;==>_ARCHIVERPROC
Func WM_COMMAND($hWnd, $Msg, $wParam, $lParam)
Local $nNotifyCode = BitShift($wParam, 16)
Local $nID = BitAND($wParam, 0xFFFF)
Switch $nNotifyCode
Case 0
Switch $nID
Case $Button2
$flc = 1
EndSwitch
EndSwitch
Return 'GUI_RUNDEFMSG'
EndFunc ;==>WM_COMMAND