AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Thema durchsuchen
Ansicht
Themen-Optionen

Delphi >> DLL >> C++

Ein Thema von Blazej · begonnen am 18. Dez 2003 · letzter Beitrag vom 18. Dez 2003
Antwort Antwort
Blazej

Registriert seit: 18. Dez 2003
3 Beiträge
 
#1

Delphi >> DLL >> C++

  Alt 18. Dez 2003, 11:35



Hi,

I have a problem using a dll written i C++ invoking from Delphi6.
How to pass pointers (type struct) to a dll ?

C++ function:
Code:
typedef struct
{       unsigned int lengt;
   unsigned char data[2096];
}MESSAGE_;

extern "C" __declspec(dllexport)
unsigned char WINAPI build_esco_format
  (MESSAGE_ *pntr,
   unsigned char comm_type,
   unsigned long source,
   unsigned long destination)
-------------------------------
Delphi function:
Delphi-Quellcode:
TYPE pMESSAGE = ^TMESSAGE_;
     TMESSAGE_ = record
     lengt: Word;
     data: Array[0..2096-1] of Char;
     end {MESSAGE};
var Message_2 : pMESSAGE;

function build_esco_format
  (Message_2 : pMESSAGE;
   comm_type : Byte;
   source : LongInt;
   destinatin: LongInt ): Byte;
   stdcall; external thedll;
[edit=sakura] Code-Tags corrected Mfg, sakura[/edit]
  Mit Zitat antworten Zitat
scp

Registriert seit: 31. Okt 2003
1.120 Beiträge
 
Delphi 7 Personal
 
#2

Re: Delphi >> DLL >> C++

  Alt 18. Dez 2003, 14:31
Simply use the @ operator:

Delphi-Quellcode:
var
  AMessage : TMESSAGE_;
  Acomm_type : Byte;
  Asource : LongInt;
  Adestination: LongInt;
  ARes :Byte;
begin
  //...
  ARes := build_esco_format(@AMessage, Acomm_type, Asource, Adestination);
  Mit Zitat antworten Zitat
Robert Marquardt
(Gast)

n/a Beiträge
 
#3

Re: Delphi >> DLL >> C++

  Alt 18. Dez 2003, 15:16
Delphi-Quellcode:
TYPE
  pMESSAGE = ^TMESSAGE_;
  TMESSAGE_ = packed record
     length: Integer;
     data: Array[0..2096-1] of Char;
  end {MESSAGE};
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 16:30 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz