dllcall / ???

  • Hy@ALL

    Hab da n Problemchen.

    Versuche ein Delphi Programm in Auto It umzusetzen.

    und hab bei ein paar zeilchen gewisse probleme..

    wenn mir jemand helfen könnte ?! Wäre echt SUPER !!

    ---------------------------------------------------------------------

    hier ein Auszug aus der DLL Description ::

    Syntax
    PROCEDURE ReadData(Buffer: Pointer);

    Parameter
    Buffer: A pointer to the data array of 8 integers where the data will be read.

    Description
    Reads the timer counter status and the A/D data from the K8047 to a buffer in the application program.
    The timer counter is incremented every 10ms. The new data from the A/D converter channels 1...4 is updated every time the timer counter is incremented.
    Data structure:

    Timer data A/D converter data Reserved
    LSB MSB CH1 CH2 CH3 CH4 0 0


    Example

    var // global variables
    DataBuffer: ARRAY[0..7] OF Integer;

    procedure TForm1.Button1Click(Sender: TObject);
    var p:pointer;
    i:integer;
    s:string;
    begin
    p:=@DataBuffer; // Address of the data buffer
    ReadData(p); // Read the data from K8047
    memo1.clear;
    s:='';
    for i:=0 to 7 do s:=s +inttostr(DataBuffer[i]+chr(9);
    memo1.lines.add(s); // Display the data
    end;

    --------------------------------------------------------------------------------
    --------------------------------------------------------------------------------

    meine bisherige lösung ::

    Dim $DataBuffer[8]

    $result = DllCall("C:\WINDOWS\system32\K8047D.dll","char","StartDevice")
    $result = DllCall("C:\WINDOWS\system32\K8047D.dll","char","LEDon")

    While 1
    sleep(200)
    $point = InputBox("start","bitte pointer eingeben","0")
    $DataBuffer[0] = DllCall("C:\WINDOWS\system32\K8047D.dll","char","ReadData","char",$point);,"int","0")
    ;DllCall(" dll","return type","function"[,"type1",param1[,"type n",param n]] )
    MsgBox(4096,"",$point & " / " & $DataBuffer[0] & " / " & $DataBuffer[1] & " / " & $DataBuffer[2] & " / " & $DataBuffer[3] & " / " & $DataBuffer[4] & " / " & $DataBuffer[5] & " / " & $DataBuffer[6] & " / " & $DataBuffer[7])

    WEnd

    -----------------------------------------------------------------------

    tut sich aber nix ... WARUM ?!

    jemand ne idee ??

    DANKE !

    Einmal editiert, zuletzt von vivus (5. Juni 2009 um 10:40)

    • Offizieller Beitrag

    Du mußt einen Buffer als Array Integer vorbereiten und auf diesen mit einem Pointer verweisen.
    Probier mal so:

    [autoit]

    $Buffer = DllStructCreate('int[8]')
    DllCall("C:\WINDOWS\system32\K8047D.dll", "char", "ReadData", "ptr", DllStructGetPtr($Buffer))
    For $i = 0 To 7
    ConsoleWrite(DllStructGetData($Buffer, 1, $i) & @CRLF)
    Next

    [/autoit]

    NB: Bist du dir beim Rückgabetyp des DllCalls sicher? "char" halte ich für wenig wahrscheinlich, "int" oder "long" wird wohl richtig sein. Wenn du eine Beschreibung zur Dll hast, schau mal nach.

  • hab's geschafft ... mein ansatz hat nicht gestimmt !!

    ----------------

    $p = DllStructCreate("dword 1;dword 2;dword 3;dword 4;dword 5;dword 6")

    ;think of this as p->dwOSVersionInfoSize = sizeof(OSVERSIONINFO)
    DllStructSetData($p, "dwOSVersionInfoSize", DllStructGetSize($p))

    ;make the DllCall
    $ret = DllCall("C:\WINDOWS\system32\K8047D.dll","short","ReadData","ptr",DllStructGetPtr($p))


    ;get the returned values
    $1 = DllStructGetData($p,"1")
    $2 = DllStructGetData($p,"2")
    $3 = DllStructGetData($p,"3")
    $4 = DllStructGetData($p,"4")
    $5 = DllStructGetData($p,"5")
    $6 = DllStructGetData($p,"6")


    ;free the struct
    $p =0


    MsgBox(0,"dllcall", "pos1 = " & $1 & @CRLF & _
    "pos2 = " & $2 & @CRLF & _
    "pos3 = " & $3 & @CRLF & _
    "pos4 = " & $4 & @CRLF & _
    "pos5 = " & $5 & @CRLF & _
    "pos6 = " & $6)


    ------------------

    GEIL !!

    wen's interessiert .. beim Velleman Versandhandelt .. gibt es einen

    USB logger .. mit 4 analog in .. 0-30 V

    für nur 30€

    den kann man jetzt mit der obigen Funktion auslesen .. via DLL

    BYE !