title: DLL C++ import functions to Delphi
body: <p>How do I access the functions of a C++ DLL in Delphi</p>
  <pre><code> #define CCONV _stdcall 
    typedef struct{ 
      unsigned long BaudRate; 
      unsigned char PortNumber; 
      ..... 
    }SSP_COMMAND;
  
  NOMANGLE int CCONV OpenSSPComPort (SSP_COMMAND * cmd);
  </code></pre>
  <p>In documentation:
  <strong>OpenSSPComPort</strong></p>
  <p>Parameters:  <strong>Pointer</strong> to SSP_COMMAND structure</p>
  <p>Returns:     WORD 0 for fail, 1 for success</p>
  <p>I suspect I am wrong about this <strong>Pointer</strong>.</p>
  <p>In Delphi I am attempting this:</p>
  <pre><code>type
    SSP_COMMAND=class
     BaudRate:integer;
     PortNumber:integer;
  end;
  
  type
   TOpenSSPComPort = function (sspc:SSP_COMMAND):Integer;stdcall;
  
      var nv11 : THandle;
      OpenSSPComPort:TOpenSSPComPort;
  
      procedure TForm1.FormCreate(Sender: TObject);
      begin
  
      if nv11 = 0 then
      begin
        nv11 := LoadLibrary(pchar('ITLSSPProc.dll'));
        @OpenSSPComPort:=GetProcAddress(nv11, 'OpenSSPComPort');
  
        ss_cmd := SSP_COMMAND.create;
  
      end;
    end;
  
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      ss_cmd.BaudRate := 9600;
      ss_cmd.PortNumber :=8;
  
     If OpenSSPComPort(ss_cmd)=0 Then
     Memo1.lines.add('Error OpenSSPComPort')
     else
     Memo1.lines.add('OpenSSPComPort - OK');
  
    end;
  </code></pre>
  <p>So result is :  COM0   - Can't open this port
  but I sent <strong>8</strong>
  this means then SSP_COMMAND was sent incorrectly</p>