Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Catalog · How the catalog works

Random project

data-transmission-delphi

Example code for blog post on dll communication with Delphi

View on GitHub

Anyone may press Interesting, signed in or not. It helps others find this project.

Member rating

No ratings yet.

Sign in to rate this project.

README

data-transmission-delphi

Example code for blog post on dll communication with Delphi

Part 1: Pointers and Structures

Part 2: Arrays and Pointer Math

Part 3: Transmitting and Interpreting Data

pascal
//Transmit records one by one
 TTXer.Send<TxLineRec>( 
    procedure(var ARec: TxLineRec) 
    begin
      ARec.p1.x := 0.5;
      ARec.p1.y := 0.25;
      ARec.p2.x := 1.0;
      ARec.p2.y := 2.0;
    end
  );
  
 // Transmit records as an array (pointer and count)
  TTxer.Send<TxPolyLineRec>(FPolylines.Count, 
    Procedure(var ARec: TxPolyLineRec; AIdx: integer)
    begin
      ARec.VertexCount := Length(FPolylines[AIdx].Vertices);
      ARec.Vertices := FPolylines[AIdx].Vertices;  
    end
  );

To see code that uses the new Intializer syntax provided in Delphi 10.4 and up please switch to the Delphi 10.4 branch