L_DicomGetUserInfoCount
#include "ltdic.h"
L_INT EXT_FUNCTION 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 |
See Also
Functions: |
L_DicomGetTypeUserInfo, L_DicomGetLengthUserInfo, L_DicomGetDataUserInfo, L_DicomSetUserInfo, L_DicomAddUserInfo, L_DicomDelUserInfo |
Topics: |
Example
#include <windowsx.h>
.
.
.
L_VOID Test(HDICOMPDU hPDU)
{
L_UCHAR i;
L_UCHAR nType;
L_UINT16 nLen;
L_CHAR szMsg[8000];
L_CHAR L_FAR *pData=NULL;
L_CHAR L_FAR *pTemp=NULL;
L_CHAR szTest1[]={"Just a test\0"};
L_CHAR szTest2[]={"a second test\0"};
/* get current user info types, lengths, and data then display them */
lstrcpy(szMsg, "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);
pTemp = (L_CHAR L_FAR*)GlobalAllocPtr(GMEM_MOVEABLE, nLen*sizeof(L_CHAR));
memcpy(pTemp, pData, nLen);
wsprintf(szMsg, "Type =%d\tLength=%d\nData = ", nType, nLen);
lstrcat(szMsg, "\n");
lstrcat(szMsg, pTemp);
GlobalFreePtr(pTemp);
}
}
else
lstrcat(szMsg, "\nNone");
MessageBox(NULL, szMsg, "Test", MB_OK);
/* add a user info item */
lstrcpy(szMsg, "Add user info item");
L_DicomAddUserInfo(hPDU, 99, szTest1, lstrlen(szTest1));
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_CHAR L_FAR*)GlobalAllocPtr(GMEM_MOVEABLE, nLen*sizeof(L_CHAR)+1);
memcpy(pTemp, pData, nLen);
pTemp[nLen]='\0';
lstrcat(szMsg, "\n");
wsprintf(szMsg, "Type =%d\tLength=%d\nData = ", nType, nLen);
lstrcat(szMsg, pTemp);
GlobalFreePtr(pTemp);
}
}
else
lstrcat(szMsg, "\nNone");
MessageBox(NULL, szMsg, "Test", MB_OK);
/* for each user info item, change the data */
for(i = 0; i<L_DicomGetUserInfoCount(hPDU); i++)
{
nType = L_DicomGetTypeUserInfo(hPDU, i);
L_DicomSetUserInfo(hPDU, i, nType, szTest2, lstrlen(szTest2));
}
lstrcpy(szMsg, "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_CHAR L_FAR*)GlobalAllocPtr(GMEM_MOVEABLE, nLen*sizeof(L_CHAR)+1);
memcpy(pTemp, pData, nLen);
pTemp[nLen]='\0';
lstrcat(szMsg, "\n");
wsprintf(szMsg, "Type =%d\tLength=%d\nData = ", nType, nLen);
lstrcat(szMsg, pTemp);
GlobalFreePtr(pTemp);
}
}
else
lstrcat(szMsg, "\nNone");
MessageBox(NULL, szMsg, "Test", MB_OK);
/* delete the one we added */
L_DicomDelUserInfo(hPDU, L_DicomGetUserInfoCount(hPDU) - 1);
lstrcpy(szMsg, "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_CHAR L_FAR*)GlobalAllocPtr(GMEM_MOVEABLE, nLen*sizeof(L_CHAR)+1);
memcpy(pTemp, pData, nLen);
pTemp[nLen]='\0';
lstrcat(szMsg, "\n");
wsprintf(szMsg, "Type =%d\tLength=%d\nData = ", nType, nLen);
lstrcat(szMsg, pTemp);
GlobalFreePtr(pTemp);
}
}
else
lstrcat(szMsg, "\nNone");
MessageBox(NULL, szMsg, "Test", MB_OK);
}