InsertIOD Example for Delphi
var
bInsert: Boolean;
hModuleIOD: THandle;
nRet, nType: Integer;
uCode: Cardinal;
begin
bInsert := false;
uCode := $100011;
nType := DICOM_IOD_TYPE_ELEMENT;
LEADDicom1.EnableMethodErrors := false;
{ Find a Module }
LEADDicom1.FindModuleIOD(DICOM_CLASS_CR_IMAGE_STORAGE, DICOM_MODULE_OVERLAY_PLANE);
hModuleIOD := LEADDicom1.CurrentIOD.hIOD;
{ if the selected item has a child, move to that level }
nRet := LEADDicom1.MoveChildIOD();
If nRet <> SUCCESS Then
bInsert := true
Else { check this level to see if IOD already exists }
begin
LEADDicom1.MoveFirstIOD(true);
nRet := LEADDicom1.FindIOD(uCode, nType, true);
If nRet <> SUCCESS Then
bInsert := true
else
hModuleIOD := LEADDicom1.CurrentIOD.hIOD;
end;
LEADDicom1.SetCurrentIOD(hModuleIOD);
LEADDicom1.EnableMethodErrors := true;
try
begin
If bInsert Then { hModuleIOD contains parent of item to insert }
begin
LEADDicom1.InsertIOD(true, nType, uCode, 'My Test IOD', 5, 'Test Description');
ShowMessage('Element inserted:'#10#13 + LEADDicom1.CurrentIOD.Name);
end
Else
ShowMessage('Element already exists:'#10#13 + LEADDicom1.CurrentIOD.Name);
end;
except
ShowMessage('Error Number: ' + IntToStr(LEADDicom1.Error));
end;
LEADDicom1.EnableMethodErrors := true;
End;