L_DicomGetUserInfoCount

Summary

Returns the number of User-defined items in the specified DICOM Associate.

Syntax

#include "ltdic.h"

L_LTDIC_API L_INT L_DicomGetUserInfoCount(hPDU)

Parameters

HDICOMPDU hPDU

A DICOM Associate handle.

Returns

The number of User-defined items in the specified DICOM Associate.

Comments

For more information about User-defined items, refer to L_DicomAddUserInfo.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Topics

Example

#include <windowsx.h> 
 
L_INT DicomGetUserInfoCountExample(HDICOMPDU hPDU) 
{ 
   L_UCHAR  i; 
   L_UCHAR  nType; 
   L_UINT16 nLen; 
   L_TCHAR   szMsg[8000]; 
   L_UCHAR *pData=NULL; 
   L_TCHAR *pTemp=NULL; 
   L_TCHAR szTest1[]={TEXT("Just a test\0")}; 
   L_TCHAR szTest2[]={TEXT("a second test\0")}; 
   L_INT   nRet; 
 
   /* get current user info types, lengths, and data then display them */ 
   lstrcpy(szMsg, TEXT("Current user type, length, data:")); 
   if(L_DicomGetUserInfoCount(hPDU) > 0)  
   { 
      for(i = 0; i<L_DicomGetUserInfoCount(hPDU); i++) 
      { 
         nType = L_DicomGetTypeUserInfo(hPDU, i); 
         nLen  = L_DicomGetLengthUserInfo(hPDU, i); 
         pData = L_DicomGetDataUserInfo(hPDU, i); 
 
         //Assuming the data is unicode text 
         pTemp = (L_TCHAR *)GlobalAllocPtr(GMEM_MOVEABLE, nLen); 
         if (pTemp == NULL) 
            return ERROR_NOT_ENOUGH_MEMORY; 
 
         memcpy(pTemp, pData, nLen); 
         wsprintf(szMsg, TEXT("Type =%d\tLength=%d\nData = "), nType, nLen); 
         lstrcat(szMsg, TEXT("\n")); 
         lstrcat(szMsg, pTemp); 
         GlobalFreePtr(pTemp); 
         pTemp = NULL; 
      } 
   } 
   else 
      lstrcat(szMsg, TEXT("\nNone")); 
   MessageBox(NULL, szMsg, TEXT("Test"), MB_OK); 
    
   /* add a user info item */ 
   lstrcpy(szMsg, TEXT("Add user info item")); 
   nRet = L_DicomAddUserInfo(hPDU, 99, (L_UCHAR * )szTest1, (L_UINT16)lstrlen(szTest1) * sizeof(L_TCHAR)); 
   if (nRet != DICOM_SUCCESS) 
      return nRet; 
 
   if(L_DicomGetUserInfoCount(hPDU) > 0)  
   { 
      for(i = 0; i<L_DicomGetUserInfoCount(hPDU); i++) 
      { 
         nType = L_DicomGetTypeUserInfo(hPDU, i); 
         nLen  = L_DicomGetLengthUserInfo(hPDU, i); 
         pData = L_DicomGetDataUserInfo(hPDU, i); 
         pTemp = (L_TCHAR *)GlobalAllocPtr(GMEM_MOVEABLE, nLen+2); 
         if (pTemp == NULL) 
            return ERROR_NOT_ENOUGH_MEMORY; 
 
         memset(pTemp, 0, nLen +2); 
         memcpy(pTemp, pData, nLen);         
         lstrcat(szMsg, TEXT("\n")); 
         wsprintf(szMsg, TEXT("Type =%d\tLength=%d\nData = "), nType, nLen); 
         lstrcat(szMsg, pTemp); 
         GlobalFreePtr(pTemp); 
         pTemp = NULL; 
      } 
   } 
   else 
      lstrcat(szMsg, TEXT("\nNone")); 
   MessageBox(NULL, szMsg, TEXT("Test"), MB_OK); 
    
   /* for each user info item, change the data */ 
   for(i = 0; i<L_DicomGetUserInfoCount(hPDU); i++) 
   { 
      nType = L_DicomGetTypeUserInfo(hPDU, i); 
      nRet = L_DicomSetUserInfo(hPDU, i, nType, (L_UCHAR * )szTest2, (L_UINT16)lstrlen(szTest2) * sizeof(L_TCHAR)); 
      if (nRet != DICOM_SUCCESS) 
         return nRet; 
   } 
    
   lstrcpy(szMsg, TEXT("Change user data")); 
   if(L_DicomGetUserInfoCount(hPDU) > 0)  
   { 
      for(i = 0; i<L_DicomGetUserInfoCount(hPDU); i++) 
      { 
         nType = L_DicomGetTypeUserInfo(hPDU, i); 
         nLen  = L_DicomGetLengthUserInfo(hPDU, i); 
         pData = L_DicomGetDataUserInfo(hPDU, i); 
         pTemp = (L_TCHAR *)GlobalAllocPtr(GMEM_MOVEABLE, nLen+2); 
         if (pTemp == NULL) 
            return ERROR_NOT_ENOUGH_MEMORY; 
 
         memset(pTemp, 0, nLen +2); 
         memcpy(pTemp, pData, nLen); 
         lstrcat(szMsg, TEXT("\n")); 
         wsprintf(szMsg, TEXT("Type =%d\tLength=%d\nData = "), nType, nLen); 
         lstrcat(szMsg, pTemp); 
         GlobalFreePtr(pTemp); 
         pTemp = NULL; 
      } 
   } 
   else 
      lstrcat(szMsg, TEXT("\nNone")); 
   MessageBox(NULL, szMsg, TEXT("Test"), MB_OK); 
    
   /* delete the one we added */ 
   L_DicomDelUserInfo(hPDU, L_DicomGetUserInfoCount(hPDU) - 1); 
   lstrcpy(szMsg, TEXT("Delete the added user")); 
   if(L_DicomGetUserInfoCount(hPDU) > 0)  
   { 
      for(i = 0; i<L_DicomGetUserInfoCount(hPDU); i++) 
      { 
         nType = L_DicomGetTypeUserInfo(hPDU, i); 
         nLen  = L_DicomGetLengthUserInfo(hPDU, i); 
         pData = L_DicomGetDataUserInfo(hPDU, i); 
         pTemp = (L_TCHAR *)GlobalAllocPtr(GMEM_MOVEABLE, nLen+2); 
         if (pTemp == NULL) 
            return ERROR_NOT_ENOUGH_MEMORY; 
 
         memset(pTemp, 0, nLen +2); 
         memcpy(pTemp, pData, nLen); 
         lstrcat(szMsg, TEXT("\n")); 
         wsprintf(szMsg, TEXT("Type =%d\tLength=%d\nData = "), nType, nLen); 
         lstrcat(szMsg, pTemp); 
         GlobalFreePtr(pTemp); 
         pTemp = NULL; 
      } 
   } 
   else 
      lstrcat(szMsg, TEXT("\nNone")); 
 
   MessageBox(NULL, szMsg, TEXT("Test"), MB_OK); 
   return DICOM_SUCCESS; 
} 
Help Version 22.0.2022.12.7
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS DICOM C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.