InsertIOD Example for C++Builder

   bool bInsert = false;
   THandle hModuleIOD;
   int nRet;
   Byte nType = DICOM_IOD_TYPE_ELEMENT;
   Cardinal uCode = 0x100011;

   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)
      bInsert = true;
   else /* check this level to see if IOD already exists */
   {
      LEADDicom1->MoveFirstIOD(true);
      nRet = LEADDicom1->FindIOD(uCode, nType, true);
      if(nRet != SUCCESS)
         bInsert = true;
      else
         hModuleIOD = LEADDicom1->CurrentIOD->hIOD;
   }
   LEADDicom1->SetCurrentIOD(hModuleIOD);
   LEADDicom1->EnableMethodErrors = true;
   try
   {
      if(bInsert) /* hModuleIOD contains parent of item to insert */
      {
         LEADDicom1->InsertIOD(true, nType, uCode, "My Test IOD", 5, "Test Description");
         ShowMessage("Element inserted:\n" + LEADDicom1->CurrentIOD->Name);
      }
      else
         ShowMessage("Element already exists:\n" + LEADDicom1->CurrentIOD->Name);
   }
   catch(ELEADDicomError *e)
   {
      ShowMessage("Error Number: " + IntToStr(LEADDicom1->Error));
   }
   LEADDicom1->EnableMethodErrors = true;