此帖我已经在我那边回答过你了:http://sky123.org/thread-181248-1-1.html
1、改了一下程序:
2、压缩打包:
3、打包后的程序:
#Region
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_UseX64=n
#EndRegion
Opt("MustDeclareVars", 1)
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include "7Zip.au3"
Global $gu_Form1 = GUICreate("数据备份器", 363, 112, -1, -1)
Global $gu_Group1 = GUICtrlCreateGroup("", 8, 0, 345, 73)
Global $gu_Label1 = GUICtrlCreateLabel("源路径", 16, 18, 40, 17)
Global $gu_Label2 = GUICtrlCreateLabel("打包至", 16, 42, 40, 17)
Global $gu_Input1 = GUICtrlCreateInput("", 56, 16, 249, 21)
Global $gu_Input2 = GUICtrlCreateInput("", 56, 40, 249, 21)
Global $gu_Button1 = GUICtrlCreateButton("..", 312, 16, 33, 17)
Global $gu_Button2 = GUICtrlCreateButton("..", 312, 40, 33, 17)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $gu_Button3 = GUICtrlCreateButton("打包", 248, 80, 49, 25)
Global $gu_Button4 = GUICtrlCreateButton("退出", 304, 80, 49, 25)
GUISetState(@SW_SHOW)
_Main()
Exit
Func _Main()
Local $r
Local $nMsg
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE, $gu_Button4
Exit
Case $gu_Button1
$r = ""
$r = FileSelectFolder("源路径", "", 2, "", $gu_Form1)
If $r <> "" And $r <> GUICtrlRead($gu_Input1) Then
GUICtrlSetData($gu_Input1, $r)
EndIf
Case $gu_Button2
$r = ""
$r = FileSelectFolder("打包至", "", 2, "", $gu_Form1)
If $r <> "" And $r <> GUICtrlRead($gu_Input2) Then
GUICtrlSetData($gu_Input2, $r)
EndIf
Case $gu_Button3
_Compress(GUICtrlRead($gu_Input1), GUICtrlRead($gu_Input2))
EndSwitch
WEnd
EndFunc ;==>_Main
Func _Compress($Src, $Dest)
If Not (FileExists($Src)) Then Return 0
If Not (FileExists($Dest)) Then DirCreate($Dest)
If Not (FileExists($Dest)) Then Return 0
Local $PkgName = @YEAR & @MON & @MDAY & "-" & @HOUR & @MIN & @SEC & ".7z"
Local $sArcName = $Dest & "\" & $PkgName
Local $sFileName = $Src & "\*"
Local $r = _7ZipAdd($gu_Form1, $sArcName, $sFileName, 0, 9, 1, 0, 0, 0, 0, 0, 0)
Return 1
EndFunc ;==>_Compress
|