GetTransferCount Example for C++ 6.0 and later
{
long i;
_bstr_t cStr;
int nID, nTransferSyntaxCount;
//create the Associate Class as Request
m_pLEADDicomNet->CreateAssociate (TRUE);
//set the Associate to the default
m_pLEADDicomNet->DefaultAssociate (m_pLEADDicomNet->GethPDU());
//display each Transfer Syntax for the first Presentation Context
cStr = "Transfer Syntax";
nID = m_pLEADDicomNet->GetPresentationID (m_pLEADDicomNet->GethPDU(), 0);
nTransferSyntaxCount = m_pLEADDicomNet->GetTransferCount (m_pLEADDicomNet->GethPDU(), nID);
for (i = 0; i<nTransferSyntaxCount; i++)
{
_bstr_t sTransferSyntax = m_pLEADDicomNet->GetTransferSyntax(m_pLEADDicomNet->GethPDU(), nID, i);
cStr = cStr + "\n" + sTransferSyntax;
}
AfxMessageBox(cStr);
//add a transfer syntax
m_pLEADDicomNet->AddTransferSyntax (m_pLEADDicomNet->GethPDU(), nID, UID_IMPLICIT_VR_LITTLE_ENDIAN);
//display each Transfer Syntax for the first Presentation Context
cStr = "Transfer Syntax--add a transfer syntax";
nTransferSyntaxCount = m_pLEADDicomNet->GetTransferCount (m_pLEADDicomNet->GethPDU(), nID);
for (i = 0; i<nTransferSyntaxCount; i++)
cStr = cStr + "\n" + m_pLEADDicomNet->GetTransferSyntax(m_pLEADDicomNet->GethPDU(), nID, i);
AfxMessageBox(cStr);
//change them
nTransferSyntaxCount = m_pLEADDicomNet->GetTransferCount (m_pLEADDicomNet->GethPDU(), nID);
for (i = 0; i<nTransferSyntaxCount; i++)
m_pLEADDicomNet->SetTransferSyntax(m_pLEADDicomNet->GethPDU(), nID, i, UID_EXPLICIT_VR_BIG_ENDIAN);
//display each Transfer Syntax for the first Presentation Context
cStr = "Transfer Syntax--changed";
nTransferSyntaxCount = m_pLEADDicomNet->GetTransferCount (m_pLEADDicomNet->GethPDU(), nID);
for (i = 0; i<nTransferSyntaxCount; i++)
{
cStr = cStr + "\n" + m_pLEADDicomNet->GetTransferSyntax(m_pLEADDicomNet->GethPDU(), nID, i);
}
AfxMessageBox(cStr);
//delete the last one
nTransferSyntaxCount = m_pLEADDicomNet->GetTransferCount (m_pLEADDicomNet->GethPDU(), nID);
m_pLEADDicomNet->DeleteTransferSyntax(m_pLEADDicomNet->GethPDU(), nID, nTransferSyntaxCount - 1);
//display each Transfer Syntax for the first Presentation Context
cStr = "Transfer Syntax--delete last one";
nTransferSyntaxCount = m_pLEADDicomNet->GetTransferCount (m_pLEADDicomNet->GethPDU(), nID);
for (i = 0; i<nTransferSyntaxCount; i++)
cStr = cStr + "\n" + m_pLEADDicomNet->GetTransferSyntax(m_pLEADDicomNet->GethPDU(), nID, i);
AfxMessageBox(cStr);
m_pLEADDicomNet->FreeAssociate (m_pLEADDicomNet->GethPDU());
}