Pavluha
03-11-2013, 15:47
Здравствуйте. В файл программы внедрён (функцией FileInstall) архив 7-zip. Мне нужно закинуть этот архив во временную папку, получить содержимое архива, переместить разархивированные файлы в место назначения и удалить временную папку. Предположим, что у пользователя не установлен архиваторы 7-zip, WinRAR и им подобные. Как распаковать архив?
Вот код программы:
GUICreate ('Тест', 500, 40)
GUICtrlCreateLabel('Распаковать в:',10,10,90,20)
$hInput = GUICtrlCreateInput('',100,10,300,20)
$hButton = GuiCtrlCreateButton('Обзор',400,10,40,20)
$hButtonNext = GUICtrlCreateButton ('Далее>',450,10,50,20)
GUISetState()
While 1
Switch GUIGetMsg()
Case -3
ExitLoop
Case $hButton
$sPath = FileSelectFolder('Выберите папку:','',4,GuiCtrlRead($hInput))
GuiCtrlSetData($hInput,$sPath)
Case $hButtonNext
_ExtractArchive()
EndSwitch
WEnd
Func _ExtractArchive()
$sDir = @TempDir & '\sljkghklsdg'
DirCreate($sDir)
FileInstall('somefile.7z',$sDir & '\somefile.7z')
_Extract($sDir & '\somefile.7z',GUICtrlRead($hInput))
DirRemove($sDir)
EndFunc
Нужна функция _Extract()
Вот код программы:
GUICreate ('Тест', 500, 40)
GUICtrlCreateLabel('Распаковать в:',10,10,90,20)
$hInput = GUICtrlCreateInput('',100,10,300,20)
$hButton = GuiCtrlCreateButton('Обзор',400,10,40,20)
$hButtonNext = GUICtrlCreateButton ('Далее>',450,10,50,20)
GUISetState()
While 1
Switch GUIGetMsg()
Case -3
ExitLoop
Case $hButton
$sPath = FileSelectFolder('Выберите папку:','',4,GuiCtrlRead($hInput))
GuiCtrlSetData($hInput,$sPath)
Case $hButtonNext
_ExtractArchive()
EndSwitch
WEnd
Func _ExtractArchive()
$sDir = @TempDir & '\sljkghklsdg'
DirCreate($sDir)
FileInstall('somefile.7z',$sDir & '\somefile.7z')
_Extract($sDir & '\somefile.7z',GUICtrlRead($hInput))
DirRemove($sDir)
EndFunc
Нужна функция _Extract()