Jump to content

SmartWim code help?


Jazkal
 Share

Recommended Posts

I am trying to get SmartWim working with AutoIt3, but I'm having trouble with the progress output.

You can get the smartwim dll here: SmartWim

They give a VBScript example:

Dim objSmartWim, ResultCode
Set objSmartWim = WScript.CreateObject("SmartWim", "objSmartWim_")
objSmartWim.File = "C:\Image.wim"
objSmartWim.Image = "My Test Image"
objSmartWim.Path = "C:\Test"
objSmartWim.Temp = "C:\WINDOWS\Temp"
ResultCode = objSmartWim.CaptureImage(False)
WScript.Echo objSmartWim.GetErrorDescription(ResultCode)
Set objSmartWim = Nothing

Sub objSmartWim_Progress(ByVal nPercent, ByVal nSeconds)
WScript.Echo nPercent & "% complete, " & nSeconds & " remaining"
End Sub

Here is what I have converted to Autoit3 so far:

Dim $objSmartWim
Dim $ResultCode
;$objSmartWim = ObjCreate("SmartWim", "objSmartWim_")
$objSmartWim = ObjCreate("SmartWim")

$objSmartWim.File = "C:\ImageTest.wim"
$objSmartWim.Image = "My Test Image"
$objSmartWim.Path = "C:\Temp"
$objSmartWim.Temp = "C:\WINDOWS\Temp"
$ResultCode = $objSmartWim.CaptureImage(False)
MsgBox(4096, "Test", $objSmartWim.GetErrorDescription($ResultCode), 5)

Any ideas?

Edited by Jazkal
Link to comment
Share on other sites

  • Moderators

See if this works.

$oSmartWim = ObjCreate("SmartWim")
If @error Then
    MsgBox(64, "Warning", "You must first register the dll.")
    $sFile = FileOpenDialog("Open Dll", @ScriptDir, "DLL (*.dll)", 1, "SmartWim.dll")
    If @error Then
        MsgBox(48, "Error", "Unable to register the dll.")
        Exit
    EndIf
    ShellExecuteWait("regsvr32.exe", '"' & $sFile & '"')
    $oSmartWim = ObjCreate("SmartWim")
    If @error Then
        MsgBox(48, "Error", "Still unable to create SmartWim Object.")
        Exit
    EndIf
EndIf

$oEvent = ObjEvent($oSmartWim, "Evt_")

With $oSmartWim
    .File = "C:\Image.wim"
    .Image = "My Test Image"
    .Path = "C:\Test"
    .Temp = "C:\WINDOWS\Temp"
    $ResultCode = .CaptureImage (False)
EndWith

MsgBox(64, "Result", $oSmartWim.GetErrorDescription ($ResultCode))
$oEvent = 0
$oSmartWim = 0

Func Evt_Progress($nPercent, $nSeconds)
    ToolTip($nPercent & "% complete, " & $nSeconds & " remaining")
EndFunc   ;==>Evt_Progress
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...