LDicomAssociate::GetUserInfoCount

#include "ltdic.h"

L_INT LDicomAssociate::GetUserInfoCount(L_VOID)

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

Returns

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

Comments

For more information about User-defined items, refer to LDicomAssociate::AddUserInfo.

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

See Also

Functions:

LDicomAssociate::GetTypeUserInfo, LDicomAssociate::GetLengthUserInfo, LDicomAssociate::GetDataUserInfo, LDicomAssociate::SetUserInfo, LDicomAssociate::AddUserInfo, LDicomAssociate::DelUserInfo

Topics:

Working with DICOM Associate Connections

Example

L_INT LDicomAssociate_GetUserInfoCountExample(LDicomAssociate *m_pDicomAssociate)
{
   L_INT    nRet;
   L_INT    i;
   L_INT    nType;
   L_INT    nLen;
   CString  cStr;
   //create the Associate Class as Request, and set to default
   m_pDicomAssociate = new LDicomAssociate(TRUE);
   m_pDicomAssociate->Default();
   //get current user info types, lengths, and data then display them
   cStr = TEXT("Current user:");
   if (m_pDicomAssociate->GetUserInfoCount() > 0) 
   {
      for (i = 0; i<m_pDicomAssociate->GetUserInfoCount(); i++)
      {
         nType = m_pDicomAssociate->GetTypeUserInfo( i);
         nLen = m_pDicomAssociate->GetLengthUserInfo( i);
         CString strData;
         CString strByte;
         L_UCHAR *pData = m_pDicomAssociate->GetDataUserInfo(i);
         if(pData)
         {
            for(L_UINT16 k= 0; k < nLen; k++)
            {
               strByte.Format(TEXT("%d"), pData[k]);
               strData += strByte;
            }
         }
         CString strTmp;
         strTmp.Format(TEXT("Type[%d]\nLength[%d]\nData[%s]"), nType, nLen,strData);
         cStr += TEXT("\n") ;
         cStr += strTmp;
      }
   }
   else
      cStr += TEXT("\nNone");
   AfxMessageBox(cStr);
   //add a user info item item
   cStr = TEXT("Add user info item");
   CString strTest = TEXT("Just a test");   
   nRet = m_pDicomAssociate->AddUserInfo( 99, (L_UCHAR *) (LPCTSTR)strTest, (L_UINT16)strTest.GetLength());
   if(nRet != DICOM_SUCCESS)
      return nRet;
   if (m_pDicomAssociate->GetUserInfoCount() > 0) 
   {
      for (i = 0; i<m_pDicomAssociate->GetUserInfoCount(); i++)
      {
         nType = m_pDicomAssociate->GetTypeUserInfo( i);
         nLen = m_pDicomAssociate->GetLengthUserInfo( i);
         L_UCHAR *pData = m_pDicomAssociate->GetDataUserInfo(i);
         CString strData; CString strByte;
         if(pData)
         {
            for(L_UINT16 k= 0; k < nLen; k++)
            {
               strByte.Format(TEXT("%d"), pData[k]);
               strData += strByte;
            }
         }
         CString strTmp;
         strTmp.Format(TEXT("Type[%d]\nLength[%d]\nData[%s]"), nType, nLen,strData);
         cStr += TEXT("\n");
         cStr += strTmp;
      }
   }
   else
      cStr += TEXT("\nNone");
   AfxMessageBox(cStr);
   //for each user info item, change the data
   strTest = TEXT("a second test");
   for (i = 0; i<m_pDicomAssociate->GetUserInfoCount(); i++)
   {
      nType = m_pDicomAssociate->GetTypeUserInfo( i);
      m_pDicomAssociate->SetUserInfo( i, (L_UCHAR)nType, (L_UCHAR *) (LPCTSTR)strTest, (L_UINT16)strTest.GetLength());
   }
   cStr = TEXT("Change user data");
   if (m_pDicomAssociate->GetUserInfoCount() > 0) 
   {
      for (i = 0; i<m_pDicomAssociate->GetUserInfoCount(); i++)
      {
         nType = m_pDicomAssociate->GetTypeUserInfo( i);
         nLen = m_pDicomAssociate->GetLengthUserInfo( i);
         L_UCHAR *pData = m_pDicomAssociate->GetDataUserInfo(i);
         CString strData; CString strByte;
         if(pData)
         {
            for(L_UINT16 k= 0; k < nLen; k++)
            {
               strByte.Format(TEXT("%d"), pData[k]);
               strData += strByte;
            }
         }
         CString strTmp;
         strTmp.Format(TEXT("Type[%d]\nLength[%d]\nData[%s]"), nType, nLen,strData);
         cStr += TEXT("\n");
         cStr += strTmp;
      }
   }
   else
      cStr += TEXT("\nNone");
   AfxMessageBox(cStr);
   //delete the one we added
   m_pDicomAssociate->DelUserInfo( m_pDicomAssociate->GetUserInfoCount() - 1);
   cStr = TEXT("Delete the added user");
   if (m_pDicomAssociate->GetUserInfoCount() > 0) 
   {
      for (i = 0; i<m_pDicomAssociate->GetUserInfoCount(); i++)
      {
         nType = m_pDicomAssociate->GetTypeUserInfo( i);
         nLen = m_pDicomAssociate->GetLengthUserInfo( i);
         L_UCHAR *pData = m_pDicomAssociate->GetDataUserInfo(i);
         CString strData; CString strByte;
         if(pData)
         {
            for(L_UINT16 k= 0; k < nLen; k++)
            {
               strByte.Format(TEXT("%d"), pData[k]);
               strData += strByte;
            }
         }
         CString strTmp;
         strTmp.Format(TEXT("Type[%d]\nLength[%d]\nData[%s]"), nType, nLen,strData);
         cStr += TEXT("\n");
         cStr += strTmp;
      }
   }
   else
      cStr += TEXT("\nNone");
   AfxMessageBox(cStr);
   //Free associate
   delete m_pDicomAssociate;
   return DICOM_SUCCESS;
}