VT_ARRAY in AutoIt?

    • Offizieller Beitrag

    Hey,

    Bin gerade dabei dieses COM Objekt in AutoIt zu implementieren:
    http://www.codeproject.com/Articles/1384/…tor-OCX-Control

    Laut Dokumentation wird das Control mit SetData gefüttert.

    Leider habe ich so gar keine Ahnung wie man ein VT_VARAINT bzw ein VT_ARRAY in AutoIt umsetzt. Ein wenig am googlen hab ich dann im Code von AutoIt Object folgende Zeilen gefunden:

    [autoit]

    $__Au3Obj_VT_ARRAY = 0x2000
    ;...
    Global Const $__Au3Obj_tagVARIANT = "word vt;word r1;word r2;word r3;ptr data; ptr"

    [/autoit]

    Ferner habe ich auch herausgefunden was ein ARRAY/SAFEARRAY ist.
    http://msdn.microsoft.com/en-us/library/…2(v=vs.85).aspx

    Also habe ich folgendes ausprobiert:

    Spoiler anzeigen
    [autoit]

    Opt("GUIOnEventMode", 1)
    Global Const $__Au3Obj_VT_ARRAY = 0x2000
    Global Const $__Au3Obj_VT_SAFEARRAY = 27
    Global Const $__Au3Obj_tagVARIANT = "word vt;word r1;word r2;word r3;ptr data; ptr"
    Global Const $__Au3Obj_tagSAFEARRAY = "ushort cDims;ushort fFeatures; ulong cbElements; ulong cLocks; ptr pvData;int rgsabound"

    [/autoit] [autoit][/autoit] [autoit]

    Global $oErrorHandler = ObjEvent("AutoIt.Error", "_ErrFunc")
    Global $oHEX = ObjCreate("HEXEDIT.HexEditCtrl.1")

    [/autoit] [autoit][/autoit] [autoit]

    Global $tVARIANT = DllStructCreate($__Au3Obj_tagVARIANT)
    Global $tSAFEARRAY = DllStructCreate($__Au3Obj_tagSAFEARRAY)
    Global $tData = DllStructCreate("byte data[256]")

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $tSAFEARRAY.cDims = 1
    ;~ $tSAFEARRAY.fFeatures = 0x0400;An array of IDispatch*.
    $tSAFEARRAY.fFeatures = 0x0800;An array of VARIANTs
    $tSAFEARRAY.cbElements = 5;
    $tData.data = "12345"
    $tSAFEARRAY.pvData = DllStructGetPtr($tData)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    GUICreate("..")
    GUISetOnEvent(-3, "_exit")
    GUICtrlCreateObj($oHEX, 8, 8, 400 - 16, 400 - 16)
    GUISetState()

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $tVARIANT.vt = $__Au3Obj_VT_SAFEARRAY
    $tVARIANT.data = DllStructGetPtr($tSAFEARRAY)

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    $oHEX.ShowAscii = True;Funktioniert
    $oHEX.SetData(DllStructGetPtr($tVARIANT), 0);Funktioniert nicht. 0 ist das Startbyte
    #cs
    ;Fehlerausgabe:
    wg.au3 (36) : ==> COM Error intercepted !
    err.number is: 0x80020005
    err.windescription: Typenkonflikt.

    [/autoit] [autoit][/autoit] [autoit]

    err.description is:
    err.source is:
    err.helpfile is:
    err.helpcontext is:
    err.lastdllerror is: 0
    err.scriptline is: 36
    err.retcode is: 0x00000000
    #ce

    [/autoit] [autoit][/autoit] [autoit][/autoit] [autoit]

    While 1
    Sleep(100)
    WEnd

    [/autoit] [autoit][/autoit] [autoit]

    Func _exit()
    Exit
    EndFunc ;==>_exit

    [/autoit] [autoit][/autoit] [autoit]

    ; User's COM error function. Will be called if COM error occurs
    Func _ErrFunc($oError)
    ; Do anything here.
    ConsoleWrite(@ScriptName & " (" & $oError.scriptline & ") : ==> COM Error intercepted !" & @CRLF & _
    @TAB & "err.number is: " & @TAB & @TAB & "0x" & Hex($oError.number) & @CRLF & _
    @TAB & "err.windescription:" & @TAB & $oError.windescription & @CRLF & _
    @TAB & "err.description is: " & @TAB & $oError.description & @CRLF & _
    @TAB & "err.source is: " & @TAB & @TAB & $oError.source & @CRLF & _
    @TAB & "err.helpfile is: " & @TAB & $oError.helpfile & @CRLF & _
    @TAB & "err.helpcontext is: " & @TAB & $oError.helpcontext & @CRLF & _
    @TAB & "err.lastdllerror is: " & @TAB & $oError.lastdllerror & @CRLF & _
    @TAB & "err.scriptline is: " & @TAB & $oError.scriptline & @CRLF & _
    @TAB & "err.retcode is: " & @TAB & "0x" & Hex($oError.retcode) & @CRLF & @CRLF)
    EndFunc ;==>_ErrFunc

    [/autoit]

    Leider gibt mir das nur den Fehler "Typkonflikt" aus. Weiß jemand wie ich ein VT_ARRAY in AutoIt hinbekommen, respektive was genau das überhaupt ist?

    Lieben Gruß und danke schon mal,
    Spider