GetExtendedData Example for C++ 6.0 or later
{
long x;
long n;
CString szOut;
CString szTemp;
VARIANT ExtData;
long lUBound;
char * pData=NULL;
BYTE b[5]={0,1,1,0,1};
SAFEARRAY FAR *psa;
SAFEARRAYBOUND rgsabound[1];
//create the Associate Class as Request
m_pLEADDicomNet->CreateAssociate(TRUE);
//set the Associate to the default
m_pLEADDicomNet->DefaultAssociate(m_pLEADDicomNet->GethPDU());
VariantInit(&ExtData);
rgsabound[0].lLbound = 0;
rgsabound[0].cElements = 5;
psa = SafeArrayCreate(VT_UI1, 1, rgsabound);
if (psa != NULL)
{
SafeArrayLock(psa);
memcpy(psa->pvData, b, 5);
SafeArrayUnlock(psa);
V_VT(&ExtData) = (VT_ARRAY | VT_UI1);
V_ARRAY(&ExtData) = psa;
m_pLEADDicomNet->SetExtendedData(m_pLEADDicomNet->GethPDU(), 1, &ExtData, 5);
SafeArrayDestroy(psa);
}
VariantClear(&ExtData);
//now, display the information
n = m_pLEADDicomNet->GetExtendedDataLength(m_pLEADDicomNet->GethPDU(), 1);
szOut = "Extended Data\n";
COleVariant VData = m_pLEADDicomNet->GetExtendedData(m_pLEADDicomNet->GethPDU(), 1);
psa = V_ARRAY(&VData);
SafeArrayGetUBound(psa, 1, &lUBound);
SafeArrayAccessData(psa, (void HUGEP**)&pData);
CString strData;
for(x=0; x<n; x++)
{
szTemp.Format("%d = %d\n", x, pData[x]);
szOut = szOut + szTemp;
}
AfxMessageBox(szOut);
SafeArrayUnaccessData(psa);
}