Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Sonstige Fragen zu Delphi (https://www.delphipraxis.net/19-sonstige-fragen-zu-delphi/)
-   -   Delphi Delphi >> DLL >> C++ (https://www.delphipraxis.net/13429-delphi-dll-c.html)

Blazej 18. Dez 2003 11:35


Delphi >> DLL >> C++
 
:cry:


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]

scp 18. Dez 2003 14:31

Re: Delphi >> DLL >> C++
 
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);

Robert Marquardt 18. Dez 2003 15:16

Re: Delphi >> DLL >> C++
 
Delphi-Quellcode:
TYPE
  pMESSAGE = ^TMESSAGE_;
  TMESSAGE_ = packed record
     length: Integer;
     data: Array[0..2096-1] of Char;
  end {MESSAGE};


Alle Zeitangaben in WEZ +1. Es ist jetzt 04:51 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