Cleware USBaccess.dll in AutoIt nutzen

  • Hi,

    ich weiß, die Frage mit dem Zugriff auf DLL-Funktionen kam schon öfter auf, aber vielleicht hilft mir das hier mal zur Klärung...

    Ich will mit AutoIt die USBaccess.dll von Cleware (http://www.cleware.de/) nutzen, damit kann man z.B. die Temperatur von einem USB-Device von Cleware auslesen. Mit C/C++ klappt das Ganze auch einwandfrei, mit AutoIt komm ich da aber auf keinen Nenner. Die Funktionen sind alle in der API.pdf (im Anhang) beschrieben und ich möchte jetzt vorherst nur eine Rückgabe, ob die Funktion aufgerufen werden kann mit AutoIt. Dazu folgender Code:

    Spoiler anzeigen
    [autoit]

    #NoTrayIcon
    #include <Array.au3>
    #include <Constants.au3>
    #include <GUIConstants.au3>
    Opt("MustDeclareVars", 0)
    main()

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

    Func _ClewareGetTemp($s_dllpath, $s_function, $s_returnval)
    Local $h_dll

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

    $h_dll = DllOpen($s_dllpath)
    If $h_dll == -1 Then
    MsgBox(16, "Error", "Unable to open " & $s_dllpath)
    EndIf

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

    DllCall($h_dll, $s_returnval, $s_function)
    Select
    Case @error == 1
    MsgBox(16, "Error", "Unable to use " & $s_dllpath)
    Case @error == 2
    MsgBox(16, "Error", "Unknown return type of " & $s_function)
    Case @error == 3
    MsgBox(16, "Error", "Function " & $s_function & " not found in " & $s_dllpath)
    EndSelect

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

    DllClose($h_dll)
    EndFunc

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

    Func main()
    Local Const $S_APPTITLE = "USB Temperature"
    Local Const $S_APPVERSION = "1.0"
    Local Const $S_DLLPATH = "USBaccess.dll"
    Local $a_harddisk, $i_maingui, $i_readtempbt, $a_msg

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

    $i_maingui = GUICreate($S_APPTITLE & " v" & $S_APPVERSION, 640, 480, -1, -1, $WS_BORDER + $WS_SYSMENU + $WS_VISIBLE)
    $i_readtempbt = GUICtrlCreateButton("&Read Temperature", 10, 10, 120, 20)

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

    While 1
    $a_msg = GUIGetMsg(1)
    Select
    Case $a_msg[0] == $GUI_EVENT_CLOSE
    ExitLoop
    Case $a_msg[0] == $i_readtempbt
    _ClewareGetTemp($S_DLLPATH, "CUSBaccess CWusb", "none")
    EndSelect
    WEnd
    GUIDelete($i_maingui)
    Exit(0)
    EndFunc

    [/autoit]

    Normalerweise müsste ich doch jetzt was anderes zurückbekommen als @error... Habs auch mit anderen Funktionen getestet. Liegt es daran, dass die DLL extra für so eine Nutzung gebaut werden muss (bin ned so der experte im umgang mit dlls...) eigentlich müsste eine Nutzung der Funktionen doch möglich sein, wenn sie als public deklariert sind...

    Achso, was ich noch gesehen hab ist, dass sie Beispiele in VB dabei haben... Das wäre ansonsten natürlich eine Alternative diese in AutoIt zu übersetzen, allerdings nutzen sie dafür ActiveX-Steuerelemente... (Wie nutzt man denn die?)

    Naja, bin mal gespannt auf Antworten. :D

    bernd670: Spoiler gesetzt!

    • Offizieller Beitrag

    Hallo

    Probier das mal, wenn es nich funktioniert ersetze die '57' mal durch '58' beim dll aufruf!

    Spoiler anzeigen
    [autoit]

    #NoTrayIcon
    #include <Array.au3>
    #include <Constants.au3>
    #include <GUIConstants.au3>
    Opt("MustDeclareVars", 0)
    main()

    Func _ClewareGetTemp($s_dllpath, $s_function, $s_returnval)
    Local $h_dll

    $h_dll = DllOpen($s_dllpath)
    If $h_dll == -1 Then
    MsgBox(16, "Error", "Unable to open " & $s_dllpath)
    EndIf
    $dllret = DllCall($h_dll,'int','OpenCleware')
    If Not @error Then MsgBox(0,"","Gefundene geräte: "&$dllret[0])
    $dllret = DllCall($h_dll,'int','57','int',1);GetTemperature(int deviceNo, double *Temperature, int *timeID) ;
    Select
    Case @error == 1
    MsgBox(16, "Error", "Unable to use " & $s_dllpath)
    Case @error == 2
    MsgBox(16, "Error", "Unknown return type of " & $s_function)
    Case @error == 3
    MsgBox(16, "Error", "Function " & $s_function & " not found in " & $s_dllpath)
    EndSelect
    If IsArray($dllret) Then MsgBox(0,"",$dllret[0])
    DllClose($h_dll)
    EndFunc

    Func main()
    Local Const $S_APPTITLE = "USB Temperature"
    Local Const $S_APPVERSION = "1.0"
    Local Const $S_DLLPATH = "USBaccess.dll"
    Local $a_harddisk, $i_maingui, $i_readtempbt, $a_msg

    $i_maingui = GUICreate($S_APPTITLE & " v" & $S_APPVERSION, 640, 480, -1, -1, $WS_BORDER + $WS_SYSMENU + $WS_VISIBLE)
    $i_readtempbt = GUICtrlCreateButton("&Read Temperature", 10, 10, 120, 20)

    While 1
    $a_msg = GUIGetMsg(1)
    Select
    Case $a_msg[0] == $GUI_EVENT_CLOSE
    ExitLoop
    Case $a_msg[0] == $i_readtempbt
    _ClewareGetTemp($S_DLLPATH, "CUSBaccess CWusb", "none")
    EndSelect
    WEnd
    GUIDelete($i_maingui)
    Exit(0)
    EndFunc

    [/autoit]

    Mfg Spider

  • Mhh, ne. Egal was ich mache. Es kommt immer der Fehler, dass die Funktion nicht gefunden wurde...

    Spoiler anzeigen
    [autoit]

    #NoTrayIcon
    #include <Array.au3>
    #include <Constants.au3>
    #include <GUIConstants.au3>
    Opt("MustDeclareVars", 0)
    main()

    Func _ClewareGetTemp($s_dllpath)
    Local $h_dll, $dllret

    $h_dll = DllOpen($s_dllpath)
    If $h_dll == -1 Then
    MsgBox(16, "Error", "Unable to open " & $s_dllpath)
    EndIf

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

    $dllret = DllCall($h_dll, "OpenCleware", "int")
    If Not @error Then
    MsgBox(0, "Debug", "Gefundene Geräte: " & $dllret[0])
    EndIf

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

    ;~ GetTemperature(int deviceNo, double *Temperature, int *timeID)
    $dllret = DllCall($h_dll, 'int', '58', 'int', 1)
    Select
    Case @error == 1
    MsgBox(16, "Error", "Unable to use " & $s_dllpath)
    Case @error == 2
    MsgBox(16, "Error", "Unknown return type.")
    Case @error == 3
    MsgBox(16, "Error", "Function not found in " & $s_dllpath)
    EndSelect
    If IsArray($dllret) Then
    MsgBox(0, "Debug", $dllret[0])
    EndIf
    DllClose($h_dll)
    EndFunc

    Func main()
    Local Const $S_APPTITLE = "USB Temperature"
    Local Const $S_APPVERSION = "1.0"
    Local Const $S_DLLPATH = @ScriptDir & "\USBaccess.dll"
    Local $a_harddisk, $i_maingui, $i_readtempbt, $a_msg

    $i_maingui = GUICreate($S_APPTITLE & " v" & $S_APPVERSION, 640, 480, -1, -1, $WS_BORDER + $WS_SYSMENU + $WS_VISIBLE)
    $i_readtempbt = GUICtrlCreateButton("&Read Temperature", 10, 10, 120, 20)

    While 1
    $a_msg = GUIGetMsg(1)
    Select
    Case $a_msg[0] == $GUI_EVENT_CLOSE
    ExitLoop
    Case $a_msg[0] == $i_readtempbt
    _ClewareGetTemp($S_DLLPATH)
    EndSelect
    WEnd
    GUIDelete($i_maingui)
    Exit(0)
    EndFunc

    [/autoit]
    • Offizieller Beitrag

    Du rufst DllCall verkehrt auf!

    nicht:

    [autoit]

    $dllret = DllCall($h_dll, "OpenCleware", "int")

    [/autoit]


    sondern:

    [autoit]

    $dllret = DllCall($h_dll, "int", "OpenCleware")

    [/autoit]
  • Ja, stimmt. soweit gefixt. Hab mal eben alles unrelevante raus genommen. Das Problem bleibt. Er gibt immer aus, dass die Funktion nicht vorhanden ist. Bei der user32.dll von Windows klappt der Zugrif aber zum Beispiel. Funktioniert das Ganze den bei Dir?

    Spoiler anzeigen
    [autoit]

    #NoTrayIcon
    #include <Array.au3>
    #include <Constants.au3>
    #include <GUIConstants.au3>
    Opt("MustDeclareVars", 0)
    main()

    Func _ClewareGetTemp($s_dllpath)
    Local $h_dll, $dllret = -1

    $h_dll = DllOpen($s_dllpath)
    If $h_dll == -1 Then
    MsgBox(16, "Error", "Unable to open " & $s_dllpath)
    EndIf

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

    $dllret = DllCall($h_dll, "int", "OpenCleware")
    Select
    Case @error == 0
    MsgBox(16, "Notification", "Gefundene Geräte: " & $dllret[0])
    Case @error == 1
    MsgBox(16, "Error", "Unable to use " & $s_dllpath)
    Case @error == 2
    MsgBox(16, "Error", "Unknown return type.")
    Case @error == 3
    MsgBox(16, "Error", "Function not found in " & $s_dllpath)
    EndSelect

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

    DllClose($h_dll)
    EndFunc

    Func main()
    Local Const $S_APPTITLE = "USB Temperature"
    Local Const $S_APPVERSION = "1.0"
    Local Const $S_DLLPATH = @ScriptDir & "\USBaccess.dll"
    Local $h_maingui, $h_readtempbt, $a_msg = -1

    $h_maingui = GUICreate($S_APPTITLE & " v" & $S_APPVERSION, 640, 480, -1, -1, $WS_BORDER + $WS_SYSMENU + $WS_VISIBLE)
    $h_readtempbt = GUICtrlCreateButton("&Read Temperature", 10, 10, 120, 20)

    While 1
    $a_msg = GUIGetMsg(1)
    Select
    Case $a_msg[0] == $GUI_EVENT_CLOSE
    ExitLoop
    Case $a_msg[0] == $h_readtempbt
    _ClewareGetTemp($S_DLLPATH)
    EndSelect
    WEnd
    GUIDelete($h_maingui)
    Exit(0)
    EndFunc

    [/autoit]
    • Offizieller Beitrag

    Ich habe die Lösung des Problems:
    [list=1]
    [*] Muß man die Funktionen verwenden die mit FCW anfangen, die anderen Funktionen können nur mit C++ oder Delphi (OOP) benutzt werden.

    [*] Bei der Erstellung der DLL wurde ein Parameter vergessen der Die Funktionsnamen auch für andere Sprachen lesbar macht. Dadurch steht vor den Funktionsnamen noch ein '_' und am Ende des Funktonsnamen steht ein '@' und eine Zahl die angibt wieviel Byte für die Parameterübergabe benötigt wird (ist abhänig von der Anzahl und Art der Parameter).
    [/list=1]


    Ich habe an den Anfang der Datei mal die Funktonsnamen geschrieben wie diese zu Verwenden sind. Die Funkton FCWSetTempOffset scheint nicht mehr oder noch nicht zu existieren, sie war zumindest nicht in der DLL enthalten.

    Spoiler anzeigen
    [autoit]

    #region Funktionsnamen aus der USBAccess.DLL
    ;~ _USBaccessInitObject@0 --> USBACCESS_API CUSBaccess * _stdcall USBaccessInitObject() ;
    ;~ _USBaccessUnInitObject@4 --> USBACCESS_API void _stdcall USBaccessUnInitObject(CUSBaccess *) ;
    ;~ _FCWInitObject@0 --> USBACCESS_API CUSBaccess * _stdcall FCWInitObject() ;
    ;~ _FCWUnInitObject@4 --> USBACCESS_API void _stdcall FCWUnInitObject(CUSBaccess *obj) ;
    ;~ _FCWOpenCleware@4 --> USBACCESS_API int _stdcall FCWOpenCleware(CUSBaccess *obj) ;
    ;~ _FCWCloseCleware@4 --> USBACCESS_API int _stdcall FCWCloseCleware(CUSBaccess *obj) ;
    ;~ _FCWRecover@8 --> USBACCESS_API int _stdcall FCWRecover(CUSBaccess *obj, int deviceNo) ;
    ;~ _FCWGetHandle@8 --> USBACCESS_API HANDLE _stdcall FCWGetHandle(CUSBaccess *obj, int deviceNo) ;
    ;~ _FCWGetValue@16 --> USBACCESS_API int _stdcall FCWGetValue(CUSBaccess *obj, int deviceNo, unsigned char *buf, int bufsize) ;
    ;~ _FCWSetValue@16 --> USBACCESS_API int _stdcall FCWSetValue(CUSBaccess *obj, int deviceNo, unsigned char *buf, int bufsize) ;
    ;~ _FCWSetLED@16 --> USBACCESS_API int _stdcall FCWSetLED(CUSBaccess *obj, int deviceNo, enum LED_IDs Led, int value) ; // value: 0=off 7=medium 15=highlight
    ;~ _FCWGetSwitch@12 --> USBACCESS_API int _stdcall FCWSetSwitch(CUSBaccess *obj, int deviceNo, enum SWITCH_IDs Switch, int On) ; // On: 0=off, 1=on
    ;~ _FCWSetSwitch@16 --> USBACCESS_API int _stdcall FCWGetSwitch(CUSBaccess *obj, int deviceNo, enum SWITCH_IDs Switch) ; // On: 0=off, 1=on, -1=error
    ;~ _FCWGetSeqSwitch@16 --> USBACCESS_API int _stdcall FCWGetSeqSwitch(CUSBaccess *obj, int deviceNo, enum SWITCH_IDs Switch, int seqNum) ; // On: 0=off, 1=on, -1=error
    ;~ _FCWGetSwitchConfig@16 --> USBACCESS_API int _stdcall FCWGetSwitchConfig(CUSBaccess *obj, int deviceNo, int *switchCount, int *buttonAvailable) ;
    ;~ *********************** --> USBACCESS_API int _stdcall FCWSetTempOffset(CUSBaccess *obj, int deviceNo, double Sollwert, double Istwert) ;
    ;~ _FCWGetTemperature@16 --> USBACCESS_API int _stdcall FCWGetTemperature(CUSBaccess *obj, int deviceNo, double *Temperature, int *timeID) ;
    ;~ _FCWGetHumidity@16 --> USBACCESS_API int _stdcall FCWGetHumidity(CUSBaccess *obj, int deviceNo, double *Humidity, int *timeID) ;
    ;~ _FCWResetDevice@8 --> USBACCESS_API int _stdcall FCWResetDevice(CUSBaccess *obj, int deviceNo) ;
    ;~ _FCWStartDevice@8 --> USBACCESS_API int _stdcall FCWStartDevice(CUSBaccess *obj, int deviceNo) ;
    ;~ _FCWCalmWatchdog@16 --> USBACCESS_API int _stdcall FCWCalmWatchdog(CUSBaccess *obj, int deviceNo, int minutes, int minutes2restart) ;
    ;~ _FCWGetVersion@8 --> USBACCESS_API int _stdcall FCWGetVersion(CUSBaccess *obj, int deviceNo) ;
    ;~ _FCWGetUSBType@8 --> USBACCESS_API int _stdcall FCWGetUSBType(CUSBaccess *obj, int deviceNo) ;
    ;~ _FCWGetSerialNumber@8 --> USBACCESS_API int _stdcall FCWGetSerialNumber(CUSBaccess *obj, int deviceNo) ;
    ;~ _FCWGetDLLVersion@0 --> USBACCESS_API int _stdcall FCWGetDLLVersion() ;
    ;~ _FCWGetManualOnCount@8 --> USBACCESS_API int _stdcall FCWGetManualOnCount(CUSBaccess *obj, int deviceNo) ;
    ;~ _FCWGetManualOnTime@8 --> USBACCESS_API int _stdcall FCWGetManualOnTime(CUSBaccess *obj, int deviceNo) ;
    ;~ _FCWGetOnlineOnCount@8 --> USBACCESS_API int _stdcall FCWGetOnlineOnCount(CUSBaccess *obj, int deviceNo) ;
    ;~ _FCWGetOnlineOnTime@8 --> USBACCESS_API int _stdcall FCWGetOnlineOnTime(CUSBaccess *obj, int deviceNo) ;
    ;~ _FCWGetMultiSwitch@20 --> USBACCESS_API int _stdcall FCWGetMultiSwitch(CUSBaccess *obj, int deviceNo, unsigned long int *mask, unsigned long int *value, int seqNumber) ;
    ;~ _FCWSetMultiSwitch@12 --> USBACCESS_API int _stdcall FCWSetMultiSwitch(CUSBaccess *obj, int deviceNo, unsigned long int value) ;
    ;~ _FCWSetMultiConfig@12 --> USBACCESS_API int _stdcall FCWSetMultiConfig(CUSBaccess *obj, int deviceNo, unsigned long int directions) ;
    ;~ _FCWGetCounter@12 --> USBACCESS_API int _stdcall FCWGetCounter(CUSBaccess *obj, int deviceNo, int counter) ;
    ;~ _FCWSyncDevice@12 --> USBACCESS_API int _stdcall FCWSyncDevice(CUSBaccess *obj, int deviceNo, unsigned long int mask) ;
    ;~ _FCWDebugWrite@8 --> USBACCESS_API void _stdcall FCWDebugWrite(CUSBaccess *obj, char *s) ;
    #endregion

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

    #NoTrayIcon
    #include <Array.au3>
    #include <Constants.au3>
    #include <GUIConstants.au3>

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

    Opt("OnExitFunc", "_OnExit")
    Opt("MustDeclareVars", 0)

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

    Global Const $cszDLLPATH = @ScriptDir & "\USBaccess.dll"

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

    Global $h_Dll = -1
    Global $ptrCUSBAccess = _Init($cszDLLPATH)

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

    main()

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

    Func _ClewareGetDLLVersion()
    $dllret = DllCall($h_Dll, "int", "_FCWGetDLLVersion@0")
    MsgBox(0,"",$dllret[0])
    EndFunc

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

    Func _ClewareGetTemp()
    Local $dllret = -1


    $dllret = DllCall($h_Dll, "int", "_FCWOpenCleware@4", "ptr", $ptrCUSBAccess)
    Select
    Case @error == 0
    MsgBox(16, "Notification", "Gefundene Geräte: " & $dllret[0])
    Case @error == 1
    MsgBox(16, "Error", "Unable to use " & $cszDLLPATH)
    Case @error == 2
    MsgBox(16, "Error", "Unknown return type.")
    Case @error == 3
    MsgBox(16, "Error", "Function not found in " & $cszDLLPATH)
    EndSelect

    EndFunc

    Func main()
    Local Const $S_APPTITLE = "USB Temperature"
    Local Const $S_APPVERSION = "1.0"
    Local $h_maingui, $h_readtempbt, $a_msg = -1

    $h_maingui = GUICreate($S_APPTITLE & " v" & $S_APPVERSION, 640, 480, -1, -1, $WS_BORDER + $WS_SYSMENU + $WS_VISIBLE)
    $h_readtempbt = GUICtrlCreateButton("&Read Temperature", 10, 10, 120, 20)
    $h_readDLLVersion = GUICtrlCreateButton("&DLL Version", 160, 10, 120, 20)

    While 1
    $a_msg = GUIGetMsg(1)
    Select
    Case $a_msg[0] == $GUI_EVENT_CLOSE
    ExitLoop
    Case $a_msg[0] == $h_readtempbt
    _ClewareGetTemp()
    Case $a_msg[0] == $h_readDLLVersion
    _ClewareGetDLLVersion()
    EndSelect
    WEnd
    GUIDelete($h_maingui)
    Exit(0)
    EndFunc

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

    Func _Init($s_dllpath)
    $h_dll = DllOpen($s_dllpath)
    If $h_dll == -1 Then
    MsgBox(16, "Error", "Unable to open " & $s_dllpath)
    Exit
    EndIf

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

    $ptrCW = DllCall($h_dll, "ptr", "_FCWInitObject@0")

    If IsArray($ptrCW) And $ptrCW[0] > 0 Then Return $ptrCW[0]
    MsgBox(16, "Error", "Invalid address on FCWInitOject!")
    Exit
    EndFunc

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

    Func _OnExit()
    DllClose($h_dll)
    EndFunc

    [/autoit]
  • bernd670

    Geile Sache. Ok, dass mit den FCW-Funktionen hatte ich wohl überlesen. Aber wie bist Du denn darauf gekommen vor die Funktion einen "_" und danach "@" zu schreiben? Anfrage beim Hersteller, oder hab ich da auch was übersehen?

    Auf jeden Fall: Vielen Dank. Echt geile Sache... :rock:

  • Mhh, Mist. Habe doch noch ein Problem. Kann zwar nun die Anzahl der Devices auslesen, nicht aber die Temperatur:

    Spoiler anzeigen
    [autoit]

    ;~ Including external files / Changing the operation of AutoIt functions/parameters.
    ;~ ----------------------------------------------------------------------------
    #NoTrayIcon
    #include <Array.au3>
    #include <GUIConstants.au3>
    Opt("GUICloseOnESC", 0)
    Opt("MustDeclareVars", 1)
    Opt("RunErrorsFatal", 0)
    ;~ -----------------------------------------------------------------------------
    main()

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

    Func _ClewareGetDLLVersion($h_dll)
    Local $i_cwversion = DllCall($h_dll, "int", "_FCWGetDLLVersion@0")

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

    Return ($i_cwversion[0])
    EndFunc ;==>_ClewareGetDLLVersion

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

    Func _ClewareInit($h_dll)
    Local $ptr_cw = DllCall($h_dll, "ptr", "_FCWInitObject@0")

    If IsArray($ptr_cw) == 0 Or $ptr_cw[0] == 0 Then
    MsgBox(16, "Error", "Invalid address on FCWInitOject!")
    Exit (1)
    EndIf

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

    Return ($ptr_cw[0])
    EndFunc ;==>_ClewareInit

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

    Func _ClewareGetTemp($h_dll, $ptr_cusbaccess)
    Local $a_cwdevices, $a_cwtemperature = -1
    Local $i_time, $d_temperature = 0

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

    $a_cwdevices = DllCall($h_dll, "int", "_FCWOpenCleware@4", "ptr", $ptr_cusbaccess)
    If $a_cwdevices[0] == 1 Then
    $a_cwtemperature = DllCall($h_dll, "int", "_FCWGetTemperature@16", "ptr", $ptr_cusbaccess, "int", 1, "ptr", $d_temperature, "int", $i_time)
    Select
    Case @error == 0
    _ArrayDisplay($a_cwtemperature)
    ;~ MsgBox(16, "Notification", "Temperatur: " & $a_cwtemperature[1] & " °C.")
    Case @error == 1
    MsgBox(16, "Error", "Unable to use DLL.")
    Case @error == 2
    MsgBox(16, "Error", "Unknown return type.")
    Case @error == 3
    MsgBox(16, "Error", "Function not found in DLL.")
    EndSelect
    EndIf
    EndFunc ;==>_ClewareGetTemp

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

    Func OnAutoItExit()
    GUIDelete($h_maingui)
    DllClose($h_dll)
    EndFunc ;==>OnAutoItExit

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

    Func main()
    Local Const $S_APPTITLE = "USB Temperature"
    Local Const $S_APPVERSION = "1.0"
    Local Const $S_DLLPATH = @ScriptDir & "\USBaccess.dll"
    Local $a_msg = -1

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

    Global $h_maingui = GUICreate($S_APPTITLE & " v" & $S_APPVERSION, 640, 480, -1, -1)
    Local $h_readtempbt = GUICtrlCreateButton("&Read Temperature", 10, 10, 120, 20)
    Local $h_readversionbt = GUICtrlCreateButton("&DLL Version", 160, 10, 120, 20)

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

    Global $h_dll = DllOpen($S_DLLPATH)
    If $h_dll == -1 Then
    MsgBox(16, "Error", 'Unable to open "' & $S_DLLPATH & '".')
    Exit (1)
    EndIf
    Local $ptr_cusbaccess = _ClewareInit($h_dll)

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

    GUISetState(@SW_SHOW, $h_maingui)
    While 1
    $a_msg = GUIGetMsg(1)
    Select
    Case $a_msg[0] == $GUI_EVENT_CLOSE
    ExitLoop 1
    Case $a_msg[0] == $h_readtempbt
    _ClewareGetTemp($h_dll, $ptr_cusbaccess)
    Case $a_msg[0] == $h_readversionbt
    MsgBox(64, "Cleware Version", _ClewareGetDLLVersion($h_dll))
    EndSelect
    WEnd
    Exit (0)
    EndFunc ;==>main

    [/autoit]

    Die Funktion _FCWGetTemperature@16 verlangt als Übergabeparameter ein double, das gibt die Funktion DLLCall aber gar nicht her. Daher die Frage, wie lässt sich das lösen?

    • Offizieller Beitrag

    Die Funktion erwartet eine ptr auf double, dass geht nur über DllStruct...!

    Spoiler anzeigen
    [autoit]

    Func _ClewareGetTemp($h_dll, $ptr_cusbaccess)
    Local $a_cwdevices, $a_cwtemperature = -1
    Local $i_time = DllStructCreate("int"), $d_temperature = DllStructCreate("double")

    DllStructSetData($d_temperature,1,0)
    DllStructSetData($i_time,1,0)

    $a_cwdevices = DllCall($h_dll, "int", "_FCWOpenCleware@4", "ptr", $ptr_cusbaccess)
    If $a_cwdevices[0] == 1 Then
    $a_cwtemperature = DllCall($h_dll, "int", "_FCWGetTemperature@16", _
    "ptr", $ptr_cusbaccess, _
    "int", 1, _
    "ptr", DllStructGetPtr($d_temperature), _
    "ptr", DllStructGetPtr($i_time))

    Select
    Case @error == 0
    $d_temperature = DllStructGetData($d_temperature,1)
    $i_time = DllStructGetData($i_time,1)
    _ArrayDisplay($a_cwtemperature)
    MsgBox(16, "Notification", "Temperatur: " & $d_temperature & " °C.")
    Case @error == 1
    MsgBox(16, "Error", "Unable to use DLL.")
    Case @error == 2
    MsgBox(16, "Error", "Unknown return type.")
    Case @error == 3
    MsgBox(16, "Error", "Function not found in DLL.")
    EndSelect
    EndIf
    EndFunc ;==>_ClewareGetTemp

    [/autoit]
    Zitat

    Aber wie bist Du denn darauf gekommen vor die Funktion einen "_" und danach "@" zu schreiben?

    Das kann man mit dem Dependency Walker auslesen!

  • Ah ja, jetzt seh ich das auch (hab die Sternchen übersehen :D). Ergibt ja auch Sinn mit dem Struct (hab noch nie so wirklich was mit DLLs in AutoIt gemacht - begreife aber so langsam aber sicher...)

    Irgendwie funzt das aber immer noch nicht. Wenn ich mir die Werte in einem Array ausgeben lassen, so stehen da anscheinend nur die Speicheradressen drin. Wie komm ich den jetzt an die Temperatur?

    Spoiler anzeigen
    [autoit]

    ;~ Including external files / Changing the operation of AutoIt functions/parameters.
    ;~ ----------------------------------------------------------------------------
    #NoTrayIcon
    #include <Array.au3>
    #include <GUIConstants.au3>
    Opt("GUICloseOnESC", 0)
    Opt("MustDeclareVars", 1)
    Opt("RunErrorsFatal", 0)
    ;~ -----------------------------------------------------------------------------
    main()

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

    Func _ClewareInit($h_dll)
    Local $ptr_cw = DllCall($h_dll, "ptr", "_FCWInitObject@0")

    If IsArray($ptr_cw) == 0 Or $ptr_cw[0] == 0 Then
    MsgBox(16, "Error", "Invalid address on FCWInitOject!")
    Exit (1)
    EndIf

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

    Return ($ptr_cw[0])
    EndFunc ;==>_ClewareInit

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

    Func _ClewareUnInit($h_dll, $ptr_cusbaccess)
    DllCall($h_dll, "ptr", "_FCWUnInitObject@4", "ptr", $ptr_cusbaccess)
    EndFunc ;==>_ClewareUnInit

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

    Func _ClewareOpen($h_dll, $ptr_cusbaccess)
    Local $i_cwdevices = DllCall($h_dll, "int", "_FCWOpenCleware@4", "ptr", $ptr_cusbaccess)

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

    Return ($i_cwdevices[0])
    EndFunc ;==>_ClewareOpen

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

    Func _ClewareClose($h_dll, $ptr_cusbaccess)
    DllCall($h_dll, "int", "_FCWCloseCleware@4", "ptr", $ptr_cusbaccess)
    EndFunc

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

    Func _ClewareGetDLLVersion($h_dll)
    Local $i_cwversion = DllCall($h_dll, "int", "_FCWGetDLLVersion@0")

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

    Return ($i_cwversion[0])
    EndFunc ;==>_ClewareGetDLLVersion

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

    Func _ClewareResetDevice($h_dll, $ptr_cusbaccess, $i_device)
    DllCall($h_dll, "int", "_FCWResetDevice@8", "ptr", $ptr_cusbaccess, "int", $i_device)
    EndFunc ;==>_ClewareResetDevice

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

    Func _ClewareGetTemperature($h_dll, $ptr_cusbaccess)
    Local $i_deviceid, $i_time, $d_temperature, $a_cwtemperature = -1

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

    $i_deviceid = _ClewareOpen($h_dll, $ptr_cusbaccess)
    If $i_deviceid == 1 Then
    MsgBox(64, "Cleware", "Number of Devices: " & $i_deviceid)
    _ClewareResetDevice($h_dll, $ptr_cusbaccess, 1)

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

    $i_time = DllStructCreate("int")
    $d_temperature = DllStructCreate("double")
    DllStructSetData($i_time, 1, 0)
    DllStructSetData($d_temperature, 1, 0)
    $a_cwtemperature = DllCall($h_dll, "int", "_FCWGetTemperature@16", _
    "ptr", $ptr_cusbaccess, _
    "int", 1, _
    "ptr", DllStructGetPtr($d_temperature), _
    "ptr", DllStructGetPtr($i_time))

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

    Select
    Case @error == 0
    _ArrayDisplay($a_cwtemperature)
    MsgBox(64, "Cleware", "Temperatur: " & $a_cwtemperature[1] & " °C.")
    Case @error == 1
    MsgBox(16, "Error", "Unable to use DLL.")
    Case @error == 2
    MsgBox(16, "Error", "Unknown return type.")
    Case @error == 3
    MsgBox(16, "Error", "Function not found in DLL.")
    EndSelect
    EndIf
    EndFunc ;==>_ClewareGetTemperature

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

    Func main()
    Local Const $S_APPTITLE = "Get USBTemp"
    Local Const $S_APPVERSION = "1.0"
    Local Const $S_DLLPATH = @ScriptDir & "\USBaccess.dll"
    Local $a_msg = -1

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

    Local $h_maingui = GUICreate($S_APPTITLE & " v" & $S_APPVERSION, 320, 240, -1, -1)
    Local $h_readtempbt = GUICtrlCreateButton("&Read Temperature", 10, 10, 120, 20)
    Local $h_readversionbt = GUICtrlCreateButton("&DLL Version", 160, 10, 120, 20)

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

    Local $h_dll = DllOpen($S_DLLPATH)
    If $h_dll == -1 Then
    MsgBox(16, "Error", 'Unable to open "' & $S_DLLPATH & '".')
    Exit (1)
    EndIf
    Local $ptr_cusbaccess = _ClewareInit($h_dll)

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

    GUISetState(@SW_SHOW, $h_maingui)
    While 1
    $a_msg = GUIGetMsg(1)
    Select
    Case $a_msg[0] == $GUI_EVENT_CLOSE
    ExitLoop 1
    Case $a_msg[0] == $h_readtempbt
    _ClewareGetTemperature($h_dll, $ptr_cusbaccess)
    Case $a_msg[0] == $h_readversionbt
    MsgBox(64, "Cleware", "DLL Version: " & _ClewareGetDLLVersion($h_dll))
    EndSelect
    WEnd
    GUIDelete($h_maingui)
    _ClewareUnInit($h_dll, $ptr_cusbaccess)
    DllClose($h_dll)
    Exit (0)
    EndFunc ;==>main

    [/autoit]
    • Offizieller Beitrag

    Zeile 18 und 19 sollte eigentlich die Temperatur und die Zeit in $d_temperatur und $i_time zurückgeben!

  • Oh, das hatte ich ja ganz übersehen. hab mir nochmal die Doku angeschaut. ich dachte bislang die Funktion liefert nur einen Wert zurück und zwar die Temperatur, also müssen wir die Werte aus dem Struct auslesen.

    Hab meinen Code mal eben vervollständigt, aber beide Werte geben nur 0 zurück, was für einen Fehler steht.

    Spoiler anzeigen
    [autoit]

    ;~ Including external files / Changing the operation of AutoIt functions/parameters.
    ;~ ----------------------------------------------------------------------------
    #NoTrayIcon
    #include <Array.au3>
    #include <GUIConstants.au3>
    Opt("GUICloseOnESC", 0)
    Opt("MustDeclareVars", 1)
    Opt("RunErrorsFatal", 0)
    ;~ -----------------------------------------------------------------------------
    main()

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

    Func _ClewareInit($h_dll)
    Local $ptr_cw = DllCall($h_dll, "ptr", "_FCWInitObject@0")

    If IsArray($ptr_cw) == 0 Or $ptr_cw[0] == 0 Then
    MsgBox(16, "Error", "Invalid address on FCWInitOject!")
    Exit (1)
    EndIf

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

    Return ($ptr_cw[0])
    EndFunc ;==>_ClewareInit

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

    Func _ClewareUnInit($h_dll, $ptr_cusbaccess)
    DllCall($h_dll, "ptr", "_FCWUnInitObject@4", "ptr", $ptr_cusbaccess)
    EndFunc ;==>_ClewareUnInit

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

    Func _ClewareOpen($h_dll, $ptr_cusbaccess)
    Local $i_cwdevices = DllCall($h_dll, "int", "_FCWOpenCleware@4", "ptr", $ptr_cusbaccess)

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

    Return ($i_cwdevices[0])
    EndFunc ;==>_ClewareOpen

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

    Func _ClewareClose($h_dll, $ptr_cusbaccess)
    DllCall($h_dll, "int", "_FCWCloseCleware@4", "ptr", $ptr_cusbaccess)
    EndFunc ;==>_ClewareClose

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

    Func _ClewareGetDLLVersion($h_dll)
    Local $i_cwversion = DllCall($h_dll, "int", "_FCWGetDLLVersion@0")

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

    Return ($i_cwversion[0])
    EndFunc ;==>_ClewareGetDLLVersion

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

    Func _ClewareResetDevice($h_dll, $ptr_cusbaccess, $i_device)
    DllCall($h_dll, "int", "_FCWResetDevice@8", "ptr", $ptr_cusbaccess, "int", $i_device)
    EndFunc ;==>_ClewareResetDevice

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

    Func _ClewareGetTemperature($h_dll, $ptr_cusbaccess)
    Local $struct_time, $struct_temp, $i_deviceid, $i_time = 0
    Local $d_temperature = 0.0

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

    $i_deviceid = _ClewareOpen($h_dll, $ptr_cusbaccess)
    If $i_deviceid == 1 Then
    MsgBox(64, "Cleware", "Number of Devices: " & $i_deviceid)
    _ClewareResetDevice($h_dll, $ptr_cusbaccess, 1)

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

    $struct_time = DllStructCreate("int")
    DllStructSetData($struct_time, 1, 0)
    $struct_temp = DllStructCreate("double")
    DllStructSetData($struct_temp, 1, 0)
    DllCall($h_dll, "int", "_FCWGetTemperature@16", _
    "ptr", $ptr_cusbaccess, _
    "int", 1, _
    "ptr", DllStructGetPtr($struct_temp), _
    "ptr", DllStructGetPtr($struct_time))
    Select
    Case @error == 0
    $d_temperature = DllStructGetData($struct_temp, 1)
    $i_time = DllStructGetData($struct_time, 1)
    MsgBox(64, "Cleware", "Temperature: " & $d_temperature & " °C." & @CR & "Time: " & $i_time & ".")
    Case @error == 1
    MsgBox(16, "Error", "Unable to use DLL.")
    Case @error == 2
    MsgBox(16, "Error", "Unknown return type.")
    Case @error == 3
    MsgBox(16, "Error", "Function not found in DLL.")
    EndSelect
    EndIf
    EndFunc ;==>_ClewareGetTemperature

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

    Func main()
    Local Const $S_APPTITLE = "Get USBTemp"
    Local Const $S_APPVERSION = "1.0"
    Local Const $S_DLLPATH = @ScriptDir & "\USBaccess.dll"
    Local $a_msg = -1

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

    Local $h_maingui = GUICreate($S_APPTITLE & " v" & $S_APPVERSION, 320, 240, -1, -1)
    Local $h_readtempbt = GUICtrlCreateButton("&Read Temperature", 10, 10, 120, 20)
    Local $h_readversionbt = GUICtrlCreateButton("&DLL Version", 160, 10, 120, 20)

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

    Local $h_dll = DllOpen($S_DLLPATH)
    If $h_dll == -1 Then
    MsgBox(16, "Error", 'Unable to open "' & $S_DLLPATH & '".')
    Exit (1)
    EndIf
    Local $ptr_cusbaccess = _ClewareInit($h_dll)

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

    GUISetState(@SW_SHOW, $h_maingui)
    While 1
    $a_msg = GUIGetMsg(1)
    Select
    Case $a_msg[0] == $GUI_EVENT_CLOSE
    ExitLoop 1
    Case $a_msg[0] == $h_readtempbt
    _ClewareGetTemperature($h_dll, $ptr_cusbaccess)
    Case $a_msg[0] == $h_readversionbt
    MsgBox(64, "Cleware", "DLL Version: " & _ClewareGetDLLVersion($h_dll))
    EndSelect
    WEnd
    GUIDelete($h_maingui)
    _ClewareUnInit($h_dll, $ptr_cusbaccess)
    DllClose($h_dll)
    Exit (0)
    EndFunc ;==>main

    [/autoit]
    • Offizieller Beitrag

    Lass mal _ClewareResetDevice($h_dll, $ptr_cusbaccess, 1) vorm auslesen der Temperatur weg, ich befürchte nämlich das das Gerät noch im Reset ist wenn Du die Temperatur abfragen willst, ein Reset soll ja nur durchgeführt werden wenn sich der Wert von $i_time mehrfach hintereinander nicht verändert!

    Ich glaube mit dem Rückgabewert hast Du auch was falsch verstanden,
    wenn die Funktion folgendermassen aufgerufen wird:

    Spoiler anzeigen
    [autoit]

    $DLLRet = DllCall($h_dll, "int", "_FCWGetTemperature@16", _
    "ptr", $ptr_cusbaccess, _
    "int", 1, _
    "ptr", DllStructGetPtr($struct_temp), _
    "ptr", DllStructGetPtr($struct_time))

    [/autoit]

    Dann befindet sich in $DLLRet[0] der Rückgabewert der Funktion, also in diesem Fall 0 = Fehler ansonsten > 0!

  • Hi,

    habe das _ClewareResetDevice($h_dll, $ptr_cusbaccess, 1) jetzt rausgenommen. Und mit dem Rückgabewert hast Du Recht, hab mich falsch ausgedrückt. Wenn ich das aber richtig verstehe, dann beinhaltet

    [autoit]

    $d_temperature = DllStructGetData($struct_temp, 1)
    $i_time = DllStructGetData($struct_time, 1)

    [/autoit]


    ja die Temperatur und die Zeit. Habs jetzt mal richtig gestellt mit der Abfrage des Rückgabewertes der Funktion, aber sie lässt sich nicht aufrufen...

    Am Gerät kann es nicht liegen. Mit dem C++ Tool kappt es wie gesagt...

    Spoiler anzeigen
    [autoit]

    #NoTrayIcon
    #include <Array.au3>
    #include <GUIConstants.au3>
    Opt("GUICloseOnESC", 0)
    Opt("MustDeclareVars", 1)
    Opt("RunErrorsFatal", 0)

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

    main()

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

    Func _ClewareInit($h_dll)
    Local $ptr_cw = DllCall($h_dll, "ptr", "_FCWInitObject@0")

    If IsArray($ptr_cw) == 0 Or $ptr_cw[0] == 0 Then
    MsgBox(16, "Error", "Invalid address on FCWInitOject!")
    Exit (1)
    EndIf

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

    Return ($ptr_cw[0])
    EndFunc ;==>_ClewareInit

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

    Func _ClewareUnInit($h_dll, $ptr_cusbaccess)
    DllCall($h_dll, "ptr", "_FCWUnInitObject@4", "ptr", $ptr_cusbaccess)
    EndFunc ;==>_ClewareUnInit

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

    Func _ClewareOpen($h_dll, $ptr_cusbaccess)
    Local $i_cwdevices = DllCall($h_dll, "int", "_FCWOpenCleware@4", "ptr", $ptr_cusbaccess)

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

    Return ($i_cwdevices[0])
    EndFunc ;==>_ClewareOpen

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

    Func _ClewareClose($h_dll, $ptr_cusbaccess)
    DllCall($h_dll, "int", "_FCWCloseCleware@4", "ptr", $ptr_cusbaccess)
    EndFunc ;==>_ClewareClose

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

    Func _ClewareGetDLLVersion($h_dll)
    Local $i_cwversion = DllCall($h_dll, "int", "_FCWGetDLLVersion@0")

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

    Return ($i_cwversion[0])
    EndFunc ;==>_ClewareGetDLLVersion

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

    Func _ClewareResetDevice($h_dll, $ptr_cusbaccess, $i_device)
    DllCall($h_dll, "int", "_FCWResetDevice@8", "ptr", $ptr_cusbaccess, "int", $i_device)
    EndFunc ;==>_ClewareResetDevice

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

    Func _ClewareGetTemperature($h_dll, $ptr_cusbaccess)
    Local $a_cwtempsuccess = -1
    Local $struct_time, $struct_temp, $i_cwtempsuccess, $i_deviceid, $i_time = 0
    Local $d_temperature = 0.0

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

    $i_deviceid = _ClewareOpen($h_dll, $ptr_cusbaccess)
    If $i_deviceid >= 1 Then
    MsgBox(64, "Cleware", "Number of Devices: " & $i_deviceid)
    ;~ _ClewareResetDevice($h_dll, $ptr_cusbaccess, 1)

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

    $struct_time = DllStructCreate("int")
    DllStructSetData($struct_time, 1, 0)
    $struct_temp = DllStructCreate("double")
    DllStructSetData($struct_temp, 1, 0)
    $a_cwtempsuccess = DllCall($h_dll, "int", "_FCWGetTemperature@16", _
    "ptr", $ptr_cusbaccess, _
    "int", 1, _
    "ptr", DllStructGetPtr($struct_temp), _
    "ptr", DllStructGetPtr($struct_time))
    _ArrayDisplay($a_cwtempsuccess)
    If $a_cwtempsuccess[0] == 0 Then
    MsgBox(64, "Error", "Error on FCWGetTemperature!")
    Else
    Select
    Case @error == 0
    $d_temperature = DllStructGetData($struct_temp, 1)
    $i_time = DllStructGetData($struct_time, 1)
    MsgBox(64, "Cleware", "Temperature: " & $d_temperature & " °C." & @CR & "Time: " & $i_time & ".")
    Case @error == 1
    MsgBox(16, "Error", "Unable to use DLL.")
    Case @error == 2
    MsgBox(16, "Error", "Unknown return type.")
    Case @error == 3
    MsgBox(16, "Error", "Function not found in DLL.")
    EndSelect
    EndIf
    EndIf
    EndFunc ;==>_ClewareGetTemperature

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

    Func main()
    Local Const $S_APPTITLE = "Get USBTemp"
    Local Const $S_APPVERSION = "1.0"
    Local Const $S_DLLPATH = @ScriptDir & "\USBaccess.dll"
    Local $a_msg = -1

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

    Local $h_maingui = GUICreate($S_APPTITLE & " v" & $S_APPVERSION, 320, 240, -1, -1)
    Local $h_readtempbt = GUICtrlCreateButton("&Read Temperature", 10, 10, 120, 20)
    Local $h_readversionbt = GUICtrlCreateButton("&DLL Version", 160, 10, 120, 20)

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

    Local $h_dll = DllOpen($S_DLLPATH)
    If $h_dll == -1 Then
    MsgBox(16, "Error", 'Unable to open "' & $S_DLLPATH & '".')
    Exit (1)
    EndIf
    Local $ptr_cusbaccess = _ClewareInit($h_dll)

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

    GUISetState(@SW_SHOW, $h_maingui)
    While 1
    $a_msg = GUIGetMsg(1)
    Select
    Case $a_msg[0] == $GUI_EVENT_CLOSE
    ExitLoop 1
    Case $a_msg[0] == $h_readtempbt
    _ClewareGetTemperature($h_dll, $ptr_cusbaccess)
    Case $a_msg[0] == $h_readversionbt
    MsgBox(64, "Cleware", "DLL Version: " & _ClewareGetDLLVersion($h_dll))
    EndSelect
    WEnd
    GUIDelete($h_maingui)
    _ClewareUnInit($h_dll, $ptr_cusbaccess)
    DllClose($h_dll)
    Exit (0)
    EndFunc ;==>main

    [/autoit]
    • Offizieller Beitrag

    Probier doch mal eine andere Funktion, z.B. FCWGetVersion oder FCWGetUSBType!

    Ubrigens zeigt @error immer den Fehlercode der letzten Funktion an, da nach DllCall noch _ArrayDisplay und MsgBox aufgerufen wird, wird der Fehlercode von DllCall überschrieben. Wobei ich jetzt nicht weiß ob MsgBox @error beeinflusst.

  • ROFL!

    Ich hab es jetzt... Ich Paddel frag die Ganze Zeit mit DeviceID=1 ab, das erste Device ist aber 0... Tja, manchmal sinds die kleinen Dinge.

    So jetzt: VIELEN DANK!