找回密码
 加入
搜索
查看: 4115|回复: 2

[系统综合] 关于GimageX显示进度条问题

[复制链接]
发表于 2010-3-8 14:35:16 | 显示全部楼层 |阅读模式
本帖最后由 liuyq 于 2010-3-8 14:53 编辑

最近要做一个恢复wim的工具,希望在恢复win时显示恢复进度。下面是我改的一段国外的代码,可在恢复过程中不显示进度(原代码也无法显示进度),请高手帮忙看一下
Dim $iRC, $oWIM, $oEvent
                $oWIM = ObjCreate("GimageX.GimageXCtrl")
        $oEvent = ObjEvent($oWIM, "ImageXEvent_")
        ProgressOn("ImageX", "Please wait ...")
                $oWIM.Source = "d:\1\1.wim"
                $oWIM.Destination = "d:\1\test"
                $oWIM.ImageIndex = 1
                $oWIM.Check = TRUE
                $oWIM.Verify = TRUE
        $iRC = $oWIM.ApplyImage
        ConsoleWrite("RC:" & @TAB & $iRC & @CRLF & "@error:" & @TAB & @error & @CRLF)
        $oEvent = 0
        $oWIM = 0
 
        ProgressOff()

 
Func ImageXEvent_Progress($iPercent, $iSeconds)
        ProgressSet($iPercent, "ETA: " & $iSeconds & " seconds")
        ConsoleWrite("ETA:" & @TAB & @TAB & $iSeconds & @CRLF & "Progress:" & @TAB & $iPercent & @CRLF)
EndFunc   ;==>ImageXEvent_Progress
GimageX 相关信息
http://www.autoitscript.com/gimagex/
 楼主| 发表于 2010-3-8 14:36:39 | 显示全部楼层
国外源代码
#cs ----------------------------------------------------------------------------
        
        AutoIt Version: 3.2.10.0
        Author:         Bj�rn Kaiser
        
        Script Function:
        Use Gimagex_com wrapper
        
#ce ----------------------------------------------------------------------------
 
#include-once
 
;===============================================================================
;
; Function Name:    _gimagex_capture()
; Description:      Captures a Folder to a .WIM-file
; Parameter(s):
; Return Value(s):  On Success - Returns 1
;                   On Failure - Returns 0
; @error Value(s):
; Author(s):
;
;===============================================================================
Func _gimagex_capture(ByRef $oWIM, $sSource, $sDest, $sName, $sDesc = 0, $sFlags = 0, $bCheck = 0, $bVer = 0, $bBoot = 0)
;~      Local $oWIM
 
        ; Parameter Checking
        ;===============================================================================
        If Not IsString($sSource) Then
                SetError(1)
                Return 0
        EndIf
        If Not IsString($sDest) Then
                SetError(2)
                Return 0
        EndIf
        If Not IsString($sName) Then
                SetError(3)
                Return 0
        EndIf
        ;===============================================================================
 
;~      $oWIM = ObjCreate("GImageX.GImageXCtrl")
        If IsObj($oWIM) Then
                With $oWIM
                        .Source = $sSource
                        .Destination = $sDest
                        .ImageName = $sName
                        If $sDesc Then .Description = $sDesc
                        If $sFlags Then .Flags = $sFlags
                        If $bCheck Then
                                .Check = True
                        Else
                                .Check = False
                        EndIf
                        If $bVer Then
                                .Verify = True
                        Else
                                .Verify = False
                        EndIf
                        
                        If $bBoot Then
                                .Bootable = True
                        Else
                                .Bootable = False
                        EndIf
                EndWith
                $oWIM.CaptureImage
        Else
                SetError(9)
                Return 0
        EndIf
;~      $oWIM = 0
        Return 1
EndFunc   ;==>_gimagex_capture
 
;===============================================================================
;
; Function Name:    _gimagex_apply()
; Description:      Applies a .WIM-file to a path
; Parameter(s):
; Return Value(s):  On Success - Returns 1
;                   On Failure - Returns 0
; @error Value(s):
; Author(s):
;
;===============================================================================
Func _gimagex_apply(ByRef $oWIM, $sSource, $sDest, $iImage, $bCheck = 0, $bVer = 0)
;~      Local $oWIM
 
        ; Parameter Checking
        ;===============================================================================
        If Not IsString($sSource) Then
                SetError(1)
                Return 0
        EndIf
        If Not IsString($sDest) Then
                SetError(2)
                Return 0
        EndIf
        If Not IsInt($iImage) Then
                SetError(3)
                Return 0
        EndIf
        ;===============================================================================
 
;~      $oWIM = ObjCreate("GImageX.GImageXCtrl")
        If IsObj($oWIM) Then
                With $oWIM
                        .Source = $sSource
                        .Destination = $sDest
                        .Image = $iImage
                        If $bCheck Then
                                .Check = True
                        Else
                                .Check = False
                        EndIf
                        If $bVer Then
                                .Verify = True
                        Else
                                .Verify = False
                        EndIf
                EndWith
                $oWIM.ApplyImage
        Else
                SetError(9)
                Return 0
        EndIf
;~      $oWIM = 0
        Return 1
EndFunc   ;==>_gimagex_apply
 
;===============================================================================
;
; Function Name:    _gimagex_object()
; Description:      Creates a GImageX object
; Parameter(s):
; Return Value(s):  On Success - Returns GImageX object
;                   On Failure - Returns 0
; @error Value(s):
; Author(s):
;
;===============================================================================
Func _gimagex_object()
        Local $oWIM
        $oWIM = ObjCreate("GImageX.GImageXCtrl")
        If IsObj($oWIM) Then
                Return $oWIM
        Else
                Return 0
        EndIf
EndFunc
#cs ----------------------------------------------------------------------------
        
        AutoIt Version: 3.2.10.0
        Author:         Bj�rn Kaiser 
        
        Script Function:
        
        
#ce ----------------------------------------------------------------------------
 
Opt("MustDeclareVars", 1)
#include <gimagex_com.au3>
Dim $iRC, $oWIM, $oEvent
$oWIM = _gimagex_object()
 
If $oWIM Then
        $oEvent = ObjEvent($oWIM, "ImageXEvent_")
        ProgressOn("ImageX", "Please wait ...")
        $iRC = _gimagex_capture($oWIM, "D:\projects", "D:\test.wim", "test")
        ConsoleWrite("RC:" & @TAB & $iRC & @CRLF & "@error:" & @TAB & @error & @CRLF)
 
        $oEvent = 0
        $oWIM = 0
 
        ProgressOff()
EndIf
 
Func ImageXEvent_Progress($iPercent, $iSeconds)
        ProgressSet($iPercent, "ETA: " & $iSeconds & " seconds")
        ConsoleWrite("ETA:" & @TAB & @TAB & $iSeconds & @CRLF & "Progress:" & @TAB & $iPercent & @CRLF)
EndFunc   ;==>ImageXEvent_Progress
 楼主| 发表于 2010-3-8 16:59:25 | 显示全部楼层
找出了个问题,不是不显示,而是没有实时显示,所有信息都在镜像恢复完成后显示,由于太快无法看到,我在ProgressSet($iPercent, "ETA: " & $iSeconds & " seconds")后加了个Sleep(1000),可以看到在镜像恢复完成后显示进度条。现在的问题如何让他实时显示。
还有个问题进度条走了两遍,不知道为什么。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-5-20 12:02 , Processed in 0.143214 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表