Hallo,
vielleicht könnte mir bitte jemand helfen um Funktionen aus einer dll, die in Delphi geschrieben wurde, aufzurufen.
Ich bin schon am verzweifeln warum das nicht klappt. Mit anderen dll's (z.B. System dll's) klappt es ohne Probleme.
Da ich das für ein Projekt in meiner Arbeit brauche wäre ich für Hilfe sehr dankbar.
Die dll kann ich öffnen und es ist mir auch möglich alle Funktionen (14) zu erreichen.
Allerdings crashed AutoIt mit der Meldung: "AutoIT3.exe ended.rc:-1073741819" wenn ich die Ininitialisierungs Funktion (Procedure trxInitialize) der dll aufrufe.
Die dll kann ich aus Copyrightgründen nicht mitgeben (kostet 750€)
Vielleicht kann mir jemand sagen mit welchem Parametertyp ich diese dll-Funktion aufrufen muss.
Ich versuche es schon seit zwei Tagen und steh jetzt total auf dem Schlauch.
Vielen Dank im Voraus für eure Hilfe.
Gruß, PixelStorm
Das ist ein Ausschnitt aus einer Datei, die mir mit der dll geliefert wurde (trxRemoteIntf.pas)
CONST
// Result codes:
trxCommOK = 0;
trxCommNACK = 1;
trxCommOutOfRange = 2;
trxCommNoFile = 3;
TYPE
// parameter type to pass string data
trxString = String[255];
// active units are returned by the initialize function
// check for non zero entries
// the number of the non-zero entries indicate the numbers
// of the TRX011 units present on the system.
// These numbers should be used to target a specific unit in
// all functions given in this interface.
// The content of the entry is the Windows handle of the TRX011 unit
TtrxUnits= Array[0..255] of Integer;
Procedure trxInitialize( Var NumberOfTRXunits : Byte;
Var AvailableTRXunits : TtrxUnits); stdcall; external 'trxRemote.dll';
// this function should be called first by the remote control program
// to find all active TRX011 units.
Alles anzeigen
Hier einmal der AutoIt Code den ich benutze:
[autoit]#include <APIErrors.au3>
#include <Array.au3>
#include <WinAPI.au3>
#include <WinAPIReg.au3>
#include <WinAPISys.au3>
#include <WindowsConstants.au3>
Global Const $trxCommOK = 0
Global Const $trxCommNACK = 1
Global Const $trxCommOutOfRange = 2
Global Const $trxCommNoFile = 3
Global $trxString = ""
Global $NumberOfTRXunits = 0
Global $AvailableTRXunits[256] = []
InitTRX_01()
InitTRX_02()
Func InitTRX_01()
Global $trxFunctions[14][2] = [["trxInitialize"],["trxIdentify"],["trxAttenuation"],["trxFrequency"],["trxPI"],["trxPS"],["trxTA"],["trxTP"], _
["trxEON_TA"],["trxEON_TP"],["trxEON_PS"],["trxLoadRDS"],["trxEAS"],["trxMode"]]
_ArrayDisplay($trxFunctions, "$trxFunctions without Address")
$handle_trxDLL = _WinAPI_LoadLibrary("trxRemote.dll")
For $i = 0 To UBound($trxFunctions) - 1
$trxFunctions[$i][1] = _WinAPI_GetProcAddress($handle_trxDLL, $trxFunctions[$i][0])
Next
_ArrayDisplay($trxFunctions, "$trxFunctions with Address")
ConsoleWrite("Function: " & $trxFunctions[0][0] & " has Address: " & $trxFunctions[0][1] & @CRLF)
$trxString = DllCallAddress("INT", $trxFunctions[0][1], "BYTE*", $NumberOfTRXunits, "INT", $AvailableTRXunits)
If @error Then
switch @error
Case 2
ConsoleWrite("unknown ""return type""")
Case 4
ConsoleWrite("bad number of parameters")
Case 5
ConsoleWrite("bad parameter")
EndSwitch
EndIf
If $handle_trxDLL Then $close_trxDLL = _WinAPI_FreeLibrary($handle_trxDLL)
ConsoleWrite("$close_trxDLL = " & $close_trxDLL & @CRLF)
EndFunc
Func InitTRX_02()
Local $funcReturn = DllCall("trxRemote.dll", "INT", "trxInitialize", "BYTE*", $NumberOfTRXunits, "INT", $AvailableTRXunits)
If @error Then
switch @error
Case 1
ConsoleWrite("unable to use the DLL file" & @CRLF)
Case 2
ConsoleWrite("unknown ""return type""" & @CRLF)
Case 3
ConsoleWrite("""function"" not found in the DLL file" & @CRLF)
Case 4
ConsoleWrite("bad number of parameters" & @CRLF)
Case 5
ConsoleWrite("bad parameter" & @CRLF)
EndSwitch
EndIf
EndFunc
Exit