Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.10.23
LEADTOOLS DICOM C DLL Help

L_DicomGetUserInfoCount

Show in webframe

#include "ltdic.h"

L_LTDIC_API L_INT L_DicomGetUserInfoCount(hPDU)

HDICOMPDU hPDU;

/* a DICOM Associate handle */

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

Parameter

Description

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

LTDIC

For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application

Platforms

Win32, x64, Linux.

See Also

Functions:

L_DicomGetTypeUserInfo, L_DicomGetLengthUserInfo, L_DicomGetDataUserInfo, L_DicomSetUserInfo, L_DicomAddUserInfo, L_DicomDelUserInfo

Topics:

Working with DICOM Associate Connections

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;
}
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.