NetReceiveAssociateRequest Example for Delphi

procedure TForm1.LEADDicomNet1NetReceiveAssociateRequest (ASender: TObject;
  hNet, hPDU: Integer);
var
   x: Integer;
   nId: Integer;
   nResult: Integer;
   strAbstract: String;
   strTransfer: String;
begin
   //we have received an AssociateRequest
   Memo1.Lines.Add('Associate Request was received');

   //check the version, if not 1, reject it
   if(LEADDICOMNet1.GetVersion (hPDU) <> 1)then
     LEADDICOMNet1.SendAssociateReject(hNet,
                                       PDU_REJECT_RESULT_PERMANENT,
                                       PDU_REJECT_SOURCE_USER,
                                       PDU_REJECT_REASON_UNKNOWN)
   else
   begin
     //send associate accept class back
     LEADDICOMNet1.CreateAssociate (False);
     LEADDICOMNet1.ResetAssociate (LEADDICOMNet1.hPDU, False);
     //copy all presentation objects from received hPDU
     //also, reply that we only support the first Transfer Syntax from the received hPDU
     for x:= 0 to LEADDICOMNet1.GetPresentationCount (hPDU) - 1 do
     begin
         nId:= LEADDICOMNet1.GetPresentationID (hPDU, x);
         strTransfer:= LEADDICOMNet1.GetTransferSyntax(hPDU, nId, 0);
         nResult:= PDU_ACCEPT_RESULT_SUCCESS;
         strAbstract:= LEADDICOMNet1.GetPresentationAbstract (hPDU, nId);
         LEADDICOMNet1.AddPresentation(LEADDICOMNet1.hPDU, nId, nResult, strAbstract);
         LEADDICOMNet1.AddTransferSyntax(LEADDICOMNet1.hPDU, nId, strTransfer);
     end;
     LEADDICOMNet1.SendAssociateAccept(hNet);
     LEADDICOMNet1.FreeAssociate (LEADDICOMNet1.hPDU);
   end;
end;