Creating a DICOM Directory Example for C++ 6.0 and later
// Use #import to incorporate the type library information.
// For example:
// #import "C:\Windows\System32\LTDicKrn14n.dll" no_namespace
// #import "C:\Windows\System32\LTDicDir14n.dll" no_namespace
void CreateDicomDirectory()
{
// Assumes CoInitialize has been called
ILEADDicomFactoryPtr
spDicomFactory( __uuidof(LEADDicomFactory));
ILEADDicomKernelPtr spDicomKernel;
LPTSTR pszLic = "LEADTOOLS OCX Copyright (c) 1991-2005"
"LEAD Technologies, Inc.";
spDicomKernel = spDicomFactory->CreateObject
(
"LEADDicomKernel.LEADDicomKernel",
pszLic
);
spDicomKernel->UnlockSupport( L_SUPPORT_MEDICAL,
L_KEY_MEDICAL);
if (spDicomKernel->IsSupportLocked(L_SUPPORT_MEDICAL))
{
spDicomFactory = NULL;
spDicomKernel = NULL;
MessageBox(NULL, "Failed to unlock the Medical Support.",
"DICOM Directory Sample",
MB_OK | MB_ICONERROR);
return;
}
ILEADDicomDirPtr spDicomDir(__uuidof(LEADDicomDir));
// Set the destination folder
spDicomDir->ResetDicomDir("C:\\Medical Images\\Patient 1");
// If it is desired to change the Implementation Class UID and
// the Implementation Version Name...
spDicomDir->ImplementationClassUID = "1.2.840.114257.0.1";
spDicomDir->ImplementationVersionName = "LEADTOOLS 14.5";
// Set the File-set Identifier
spDicomDir->SetFileSetID("SOME ID");
// We need icon images to be added
spDicomDir->InsertIconImageSequence = VARIANT_TRUE;
// Don't allow invalid File IDs
spDicomDir->RejectInvalidFileID = VARIANT_TRUE;
// Set the File-set descriptor file
spDicomDir->SetDescriptorFile("C:\\Medical Images\\Patient 1\\ReadMe", "");
// Enable generating runtime exceptions
spDicomDir->EnableMethodErrors = VARIANT_TRUE;
// Add some DICOM files to the Directory
spDicomDir->InsertDicomFile("C:\\Medical Images\\Patient 1\\Image1");
spDicomDir->InsertDicomFile("C:\\Medical Images\\Patient 1\\Image2");
spDicomDir->InsertDicomFile("C:\\Medical Images\\Patient 1\\Image3");
// Disable generating runtime exceptions
spDicomDir->EnableMethodErrors = VARIANT_FALSE;
// Save the DICOMDIR File
spDicomDir->SaveDicomDir();
spDicomFactory = NULL;
spDicomKernel = NULL;
spDicomDir = NULL;
// remember to call CoUninitialize() when your
// app no longer needs COM Objects
}