#include "Ltdic.h"

L_UINT16 LDicomDir::InsertDicomDS(DataSet, pszFileName)

Adds a DICOM Data Set to the Dicom Directory.


LDicomDS& DataSet

The LDicomDS object that holds the Data Set to be added to the Dicom Directory.

L_TCHAR* pszFileName

Character string that contains the name of the DICOM file referenced by the object "DataSet".


Value Meaning
0 The function was successful.
> 0 An error occurred. Refer to Return Codes.


If the name of a DICOM file is to be specified, then before using this function, a destination folder must have been specified, either at the construction time or by the function LDicomDir::ResetDicomDir. Otherwise, the function will fail.

The DICOM filename must refer to an existing file that resides in the destination folder or in a subfolder of the destination folder. Otherwise, the function will fail and the Data Set will not be added to the Dicom Directory. Please notice that the filename passed to the function must specify the absolute path of the file, not the relative one.

If the parameter pszFileName is set to NULL, a Data Set can still be added, even if no destination folder is specified. (That is, if pszFileName is set to NULL and the destination folder has not been set, a Data Set can still be added.) In this case, no DICOM file will be referenced for this Data Set (i.e., the corresponding Referenced File ID (0004,1500) will have an empty value).

Required DLLs and Libraries


Win32, x64

See Also




L_INT LDicomDir_InsertDicomDSExample() 
   L_INT nRet; 
   LDicomDir DicomDir; 
   // Set the destination folder 
   nRet = DicomDir.ResetDicomDir(MAKE_IMAGE_PATH(TEXT("Medical Images\\Patient 1"))); 
   if(nRet != DICOM_SUCCESS) 
      return nRet; 
   // Set the File-set Identifier 
   nRet = DicomDir.SetFileSetID(TEXT("SOME ID")); 
   if(nRet != DICOM_SUCCESS) 
      return nRet; 
   // Don't allow invalid File IDs 
   nRet = DicomDir.GetOptions(&Options, sizeof(DICOMDIROPTIONS)); 
   if(nRet != DICOM_SUCCESS) 
      return nRet; 
   nRet = DicomDir.SetOptions(&Options); 
   if(nRet != DICOM_SUCCESS) 
      return nRet; 
   // This example assumes that IMAGE1, IMAGE2, and IMAGE3 all exist in the folder \Medical Images\Patient 1 
   // To run this sample, create this folder  
   // * C:\\LEADTOOLS21\\Resources\\Images\\Medical Images\Patient 1 
   // * Copy image1.dcm, image2.dcm, and image3.dcm to this folder 
   // * Rename the three files so they have no extension (i.e. image1, image2, image3) 
   // Set the File-set descriptor file 
   nRet = DicomDir.SetDescriptorFile(MAKE_IMAGE_PATH(L_TEXT("Medical Images\\Patient 1\\README")), NULL); 
   if(nRet != DICOM_SUCCESS) 
      return nRet; 
   // Load a Data Set and add it to the Directory 
   LDicomDS DicomDS; 
   nRet = DicomDS.LoadDS(MAKE_IMAGE_PATH(TEXT("Medical Images\\Patient 1\\Image1")), DS_LOAD_CLOSE); 
   if(nRet != DICOM_SUCCESS) 
      return nRet; 
   nRet = DicomDir.InsertDicomDS(DicomDS, MAKE_IMAGE_PATH(TEXT("Medical Images\\Patient 1\\IMAGE1"))); 
   if(nRet != DICOM_SUCCESS) 
      return nRet; 
   // Add some DICOM files to the Directory 
   nRet = DicomDir.InsertDicomFile(MAKE_IMAGE_PATH(TEXT("Medical Images\\Patient 1\\IMAGE2"))); 
   if(nRet != DICOM_SUCCESS) 
      return nRet; 
   nRet = DicomDir.InsertDicomFile(MAKE_IMAGE_PATH(TEXT("Medical Images\\Patient 1\\IMAGE3"))); 
   if(nRet != DICOM_SUCCESS) 
      return nRet; 
   // Save the DICOMDIR File 
   nRet = DicomDir.SaveDicomDir(); 
   if(nRet != DICOM_SUCCESS) 
      return nRet; 
   return DICOM_SUCCESS; 
Help Version 21.0.2021.4.7
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS DICOM C++ Class Library Help