Autor Beitrag
mb_wt
Hält's aus hier
Beiträge: 2



BeitragVerfasst: Mo 22.09.03 14:12 
Hallo,

ich habe eine DLL-Datei mit Functionen die ich ansprechen möchte.
Zu dieser DLL eine Header-Datei um die Functionen unter C++ anzusprechen.
Wie kann ich nun die Functionen unter Delphi ansprechen.
Den Functionen in der DLL-Datei werden Pointer auf Struct´s übergeben.

z.B.:

ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
struct REFERENCE
{
  unsigned char        board_select; 
  unsigned char        access;
};


struct dpn_interface
{
   struct   REFERENCE  reference;
   unsigned char       stat_nr;
   unsigned char       length;
   unsigned short int  error_code;
   unsigned char       slv_state;
   unsigned char       sys_state;
   unsigned char       sys_event;
   unsigned char       user_data [MAX_DATA_LEN];
};


Kann ich diese struct in eine Delphi Record umsetzen??
Wenn ja wie??


Gruß

Moderiert von user profile iconKlabautermann: Code-Tags hinzugefügt.
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Mo 22.09.03 15:45 
Hallo,

ich versuche es mal, übernehme aber keine Garantie ;)

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
REFERENCE = packed record
  board_select : Char; 
  access : Char; 
end


dpn_interface = packed Record 
   reference : REFERENCE
   stat_nr : Char; 
   length : Char; 
   error_code : Byte;  // unsigned shortint ist doch 8 Bit oder?
   slv_state : Char; 
   sys_state : Char; 
   sys_event : Char; 
   user_data ARRAY[MAX_DATA_LEN] OF Char; 
end;


Gruß
Klabautermann


Zuletzt bearbeitet von Klabautermann am Mo 22.09.03 19:40, insgesamt 1-mal bearbeitet
UC-Chewie
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 531

WinXP
D5 Ent
BeitragVerfasst: Mo 22.09.03 16:48 
Short Int ist ein 2 Byte-Integer, da unsigned ist es Word. Oder nicht?

_________________
Egal wie dumm man selbst ist, es gibt immer andere, die noch dümmer sind
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Mo 22.09.03 17:22 
unsigned char ist ein Byte und unsigned short ist ein Word...

die Übersetzung muss also so ausschaun:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
REFERENCE = packed record
  board_select : Byte;
  access : Byte; 
end


dpn_interface = packed Record 
   reference : REFERENCE
   stat_nr : Byte;
   length : Byte;
   error_code : Word;
   slv_state : Byte;
   sys_state : Byte;
   sys_event : Byte;
   user_data ARRAY [0..MAX_DATA_LEN - 1or Byte;
end;

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: Mo 22.09.03 19:39 
Hi,
UC-Chewie hat folgendes geschrieben:
Short Int ist ein 2 Byte-Integer, da unsigned ist es Word. Oder nicht?

wenn es zwei Byte sind dann auf jedenfall Word;

Motzi hat folgendes geschrieben:
unsigned char ist ein Byte

Byte und Char sind Äquivalent. Beide genau ein Byte Land und beide unsigned. Das eine Wird nur standartmäßig als Buchstabe und das ander als Zahl interpretiert.

Gruß
Klabautermann
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: Mo 22.09.03 19:56 
Seit ihr euch da ganz sicher, dass es sich um einen packed record handelt? Ich sehe im Ausgangscode keine Anweisung die das impliziet aussagt. Des weiteren kann auch nicht die Standardeinstellung eines bestimmten Compiler verwendet werden, da mb_wt den Compilernamen auch nicht genannt hat.

_________________
Ist Zeit wirklich Geld?
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: Di 23.09.03 10:38 
Solche records sind in den meisten Fällen "packed", aber selbst wenn nicht wäre es auch egal, da die Felder des Records so angeordnet sind, dass sie alle an entsprechenden Speichergrenzen ausgerichtet sind, womit kein Unterschied mehr entsteht ob der Record nun "packed" ist oder nicht...

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!