GetPresentationCount Example for Delphi
var
x: Integer;
id: Integer;
maxID: Integer;
strOut: String;
begin
//create the Associate Class as Request
LEADDICOMNet1.CreateAssociate (True);
//set the Associate to the default
LEADDICOMNet1.DefaultAssociate (LEADDICOMNet1.hPDU);
//get current id//s and display them
strOut:= '';
maxID:= 0;
for x:= 0 to LEADDICOMNet1.GetPresentationCount (LEADDICOMNet1.hPDU) - 1 do
begin
id:= LEADDICOMNet1.GetPresentationID (LEADDICOMNet1.hPDU, x);
strOut:= strOut + IntToStr(id);
strOut:= strOut + Chr(13);
//store the highest id
if(id > maxID)then
maxID:= id;
end;
ShowMessage(strOut);
id:= maxID + 2; //id must be unique and odd number
//change the some ids and then display them all
for x:= 0 to LEADDICOMNet1.GetPresentationCount (LEADDICOMNet1.hPDU) - 1 do
begin
LEADDICOMNet1.SetPresentationID (LEADDICOMNet1.hPDU, x, id);
id:= id + 2 //id must be odd number
end;
strOut:= '';
for x:= 0 to LEADDICOMNet1.GetPresentationCount (LEADDICOMNet1.hPDU) - 1 do
begin
strOut:= strOut + IntToStr(LEADDICOMNet1.GetPresentationID (LEADDICOMNet1.hPDU, x));
strOut:= strOut + Chr(13);
end;
ShowMessage(strOut);
//add a presentation context
strOut:= '';
LEADDICOMNet1.AddPresentation(LEADDICOMNet1.hPDU, 1, PDU_ACCEPT_RESULT_SUCCESS, UID_CT_IMAGE_STORAGE);
for x:= 0 to LEADDICOMNet1.GetPresentationCount (LEADDICOMNet1.hPDU) - 1 do
begin
strOut:= strOut + IntToStr(LEADDICOMNet1.GetPresentationID (LEADDICOMNet1.hPDU, x));
strOut:= strOut + Chr(13);
end;
ShowMessage(strOut);
//delete the one we added
strOut:= '';
LEADDICOMNet1.DeletePresentation(LEADDICOMNet1.hPDU, 1);
for x:= 0 to LEADDICOMNet1.GetPresentationCount (LEADDICOMNet1.hPDU) - 1 do
begin
strOut:= strOut + IntToStr(LEADDICOMNet1.GetPresentationID (LEADDICOMNet1.hPDU, x));
strOut:= strOut + Chr(13);
end;
ShowMessage(strOut);
LEADDICOMNet1.FreeAssociate (LEADDICOMNet1.hPDU);
end;