GetUserInfoCount Example for C#
//LEADDICOMNet1 is a predefined LEADDicomNet object
private void TestGetUserInfoCount ()
{
int x = 0;
int y = 0;
short nType = 0;
int nLen = 0;
object pData = null;
string Out = null;
object test = null ;
//create the Associate Class as Request
LEADDICOMNet1.CreateAssociate(true);
//set the Associate to the default
LEADDICOMNet1.DefaultAssociate(LEADDICOMNet1.hPDU);
//get current user info types, lengths, and data then
display them
Out = "";
if (LEADDICOMNet1.GetUserInfoCount(LEADDICOMNet1.hPDU)
> 0)
{
for (x = 0; x < LEADDICOMNet1.GetUserInfoCount(LEADDICOMNet1.hPDU);
x++)
{
nType = LEADDICOMNet1.GetUserInfoType(LEADDICOMNet1.hPDU,
x);
Out = Out + "Type:
" + System.Convert.ToString(nType);
nLen = LEADDICOMNet1.GetUserInfoLength(LEADDICOMNet1.hPDU,
x);
Out = Out + "
Length: " + System.Convert.ToString(nLen);
pData = LEADDICOMNet1.GetUserInfoData(LEADDICOMNet1.hPDU,
x);
Out = Out + "
Data: ";
for (y = 0; y <
nLen; y++)
{
Out
= Out + (char)(((byte[])pData)[y]);
}
Out = Out + "\r";
}
}
else
Out = "None";
MessageBox.Show(Out);
//add a user info item item
Out = "";
test = "just a test";
nLen = ((string)test).Length;
LEADDICOMNet1.AddUserInfo(LEADDICOMNet1.hPDU,
99, ref test, (short)((string)test).Length);
Out = "";
if (LEADDICOMNet1.GetUserInfoCount(LEADDICOMNet1.hPDU)
> 0)
{
for
(x = 0; x < LEADDICOMNet1.GetUserInfoCount(LEADDICOMNet1.hPDU);
x++)
{
nType
= LEADDICOMNet1.GetUserInfoType(LEADDICOMNet1.hPDU,
x);
Out
= Out + "Type: " + System.Convert.ToString(nType);
nLen
= LEADDICOMNet1.GetUserInfoLength(LEADDICOMNet1.hPDU, x);
Out
= Out + " Length: " + System.Convert.ToString(nLen);
pData
= LEADDICOMNet1.GetUserInfoData(LEADDICOMNet1.hPDU,
x);
Out
= Out + " Data: ";
for
(y = 0; y < nLen; y++)
{
Out
= Out + (char)(((byte[])pData)[y]);
}
Out
= Out + "\r";
}
}
else
Out
= "None";
MessageBox.Show(Out);
//for each user info
item, change the data
test = "a second
test";
for (x = 0; x <
LEADDICOMNet1.GetUserInfoCount(LEADDICOMNet1.hPDU);
x++)
{
nType
= LEADDICOMNet1.GetUserInfoType(LEADDICOMNet1.hPDU,
x);
LEADDICOMNet1.SetUserInfo(LEADDICOMNet1.hPDU,
x, nType, ref test, (short)((string)test).Length);
}
Out = "";
if (LEADDICOMNet1.GetUserInfoCount(LEADDICOMNet1.hPDU)
> 0)
{
for
(x = 0; x < LEADDICOMNet1.GetUserInfoCount(LEADDICOMNet1.hPDU);
x++)
{
nType
= LEADDICOMNet1.GetUserInfoType(LEADDICOMNet1.hPDU,
x);
Out
= Out + "Type: " + System.Convert.ToString(nType);
nLen
= LEADDICOMNet1.GetUserInfoLength(LEADDICOMNet1.hPDU, x);
Out
= Out + " Length: " + System.Convert.ToString(nLen);
pData
= LEADDICOMNet1.GetUserInfoData(LEADDICOMNet1.hPDU,
x);
Out
= Out + " Data: ";
for
(y = 0; y < nLen; y++)
{
Out
= Out + (char)(((byte[])pData)[y]);
}
Out
= Out + "\r";
}
}
else
Out
= "None";
MessageBox.Show(Out);
//delete
the one we added
LEADDICOMNet1.DeleteUserInfo(LEADDICOMNet1.hPDU,
LEADDICOMNet1.GetUserInfoCount(LEADDICOMNet1.hPDU)
- 1);
LEADDICOMNet1.FreeAssociate(LEADDICOMNet1.hPDU);
}