Autor Beitrag
Henry
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 619

WinXP Prof. SP3
D6 Prof.
BeitragVerfasst: Di 20.09.05 11:46 
Hallo,

ich habe eine Dll und ein Beispiel für die Deklaration in VB.
Nun wollte ich hier mal fragen ob mir jemand den VB Code in Delphi übersetzen könnte, damit ich die DLL in mein Programm einbinden kann. Leider kann ich selber kein VB und kann somit die Deklaration nicht selber portieren.

Ich danke schon einmal herzlich im Voraus für die Hilfe.

Hier folgt der VB-Code:
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
Private Declare Function RCInitBoxes Lib "jnutl.dll" Alias "_InitBoxes@0" () As Long
Private Declare Function RCOpenBox Lib "jnutl.dll" Alias "_OpenBox@8" (ByVal boxnumber As Long, ByRef DLLBoxConfiguration As RaceControlBoxConfiguration) As Long
Private Declare Function RCRXData Lib "jnutl.dll" Alias "_RX_data@8" (ByVal boxnumber As Long, ByVal RXData As Byte) As Long
Private Declare Function RCTXData Lib "jnutl.dll" Alias "_Get_TXDat@4" (ByVal boxnumber As Long) As Integer
Private Declare Function RCGetEvent Lib "jnutl.dll" Alias "_Get_Event@4" (ByRef DLLEvent As RaceControlEvent) As Long
Private Declare Function RCLongSub Lib "jnutl.dll" Alias "_JNLongSub@8" (ByVal Value1 As Long, Value2 As Long) As Long


ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
Private Type RaceControlBoxConfiguration
    res0 As Integer
    res1 As Integer
    level As Integer
    verz As Integer
    nachl As Integer
    zzx As Boolean
    szx As Boolean
    enable As Boolean
End Type


ausblenden Quelltext
1:
2:
3:
4:
Private Type RaceControlEvent
    comm As Long
    wcnt As Long
End Type

_________________
mfg Henry
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Di 20.09.05 21:03 
Besser wäre, wenn du die C/C++ Deklaration hättest. Der VB Code sieht mir so zusammen gewürfelt aus.
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
type
  TRaceControlBoxConfiguration = packed record
    res0: Smallint;
    res1: Smallint;
    level: Smallint;
    verz: Smallint;
    nachl: Smallint;
    zzx: WordBool;
    szx: WordBool;
    enable: WordBool;
  end;

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
type
  TRaceControlEvent = packed record
    comm: Integer;
    wcnt: Integer;
  end;

ausblenden Delphi-Quelltext
1:
2:
const
  jnutl = 'jnutl.dll';

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
function RCInitBoxes: Integer; stdcall; external jnutl name '_InitBoxes@0';
function RCOpenBox(boxnumber: Integer; var DLLBoxConfiguration: TRaceControlBoxConfiguration): Integer; stdcall; external jnutl name '_OpenBox@8';
function RCRXData(boxnumber: Integer; RXData: Byte): Integer; stdcall; external jnutl name '_RX_data@8';
function RCTXData(boxnumber: Integer): Integer; stdcall; external jnutl name '_Get_TXDat@4';
function RCGetEvent(var DLLEvent: TRaceControlEvent): Integer; stdcall; external jnutl name '_Get_Event@4';
function RCLongSub(Value1, Value2: Integer): Integer; stdcall; external jnutl name '_JNLongSub@8';

_________________
Ciao, Sprint.
Henry Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 619

WinXP Prof. SP3
D6 Prof.
BeitragVerfasst: Di 20.09.05 21:22 
Danke Dir für die Mühe.

Ich kann Dir hier mal den Link zur Doku der DLL geben, aber da ist nicht direkt eine Deklaration drin.
www.racecontrol.com/downloads/RC-DLL_d.pdf
Ich bin schon froh, das ich die oben angegebene Deklaration bekommen konnte.
Werde Deine "Übersetzung" auf jeden fall probieren.

_________________
mfg Henry
Sprint
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 849



BeitragVerfasst: Di 20.09.05 21:59 
Aus dem PDF:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
byte    vorzeichenlose 8 Bit Zahl (0...255)
int     15 Bit Zahl mit Vorzeichen (-32768 ... 32767)
word    vorzeichenlose 16 Bit Zahl (0...65535)
bool    16 Bit Boolean (0 = false, <> 0: true)
long    31 Bit Zahl mit Vorzeichen (0x80000000 ... 0x7fffffff)
dword   vorzeichenlose 32 Bit Zahl (0...0xffffffff)


ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
word _InitBoxes@0 (void)
word _OpenBox@8 (word boxnum, struct BOXCONFIGURATION *p)
word _RX_data@8 (word boxnum, byte rxdata)
word Get_Event (struct EVENT *P)
long _Get_TStamp@4 (word boxnum)
int _Get_TXDat@4 (word boxnum)
word _Timeout_Check@0 (void)
long _JNLongAdd@0 (long a, long b)
long _JNLongSub@0 (long a, long b)


ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
struct BOXCONFIGURATION
{
  word res0; // reserviert
  word res1; // reserviert
  word level; // Empfindlichkeit (0...130)
  word verz; // Verzögerung in ms (0...50)
  word nachl; // Nachlauf (0...15)
  bool zzx; // Zwischenzeitsensor R/L getauscht
  bool szx; // Start-/Zielsensor R/L getauscht
  bool enable; // Überwachung der Box-Parameter
};


ausblenden Quelltext
1:
2:
3:
4:
5:
struct EVENT
{
  long comm;
  long wcnt;
};


Also nach diesen Informationen, würde ich es mal so vesuche:

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
type
  TRCBoxConfiguration = packed record
    res0: Word;
    res1: Word;
    level: Word;
    verz: Word;
    nachl: Word;
    zzx: WordBool;
    szx: WordBool;
    enable: WordBool;
  end;

type
  TRCEvent = packed record
    comm: Integer;
    wcnt: Integer;
  end;

const
  jnutl = 'jnutl.dll';

function RCInitBoxes: Word; stdcall; external jnutl name '_InitBoxes@0';
function RCOpenBox(boxnum: Word; var p: TRCBoxConfiguration): Word; stdcall; external jnutl name '_OpenBox@8';
function RCRXData(boxnum: Word; rxdata: Byte): Word; stdcall; external jnutl name '_RX_data@8';
function RCGetEvent(var p: TRCEvent): Word; stdcall; external jnutl name 'Get_Event';
function RCGetTStamp(boxnum: Word): Integer; stdcall; external jnutl name '_Get_TStamp@4';
function RCGetTXDat(boxnum: Word): Smallint; stdcall; external jnutl name '_Get_TXDat@4';
function RCTimeoutCheck: Word; stdcall; external jnutl name '_Timeout_Check@0';
function RCLongAdd(a, b: Integer): Integer; stdcall; external jnutl name '_JNLongAdd@0';
function RCLongSub(a, b: Integer): Integer; stdcall; external jnutl name '_JNLongSub@0';

_________________
Ciao, Sprint.
Henry Threadstarter
ontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic starofftopic star
Beiträge: 619

WinXP Prof. SP3
D6 Prof.
BeitragVerfasst: Di 20.09.05 22:12 
Super, Danke nochmals für deine Mühe.
Werde ich dann bei gelegenheit probieren

_________________
mfg Henry