GetUserInfoCount Example for Delphi
var
x: Integer;
y: Integer;
nType: Integer;
nLen: Integer;
vData: OleVariant;
strOut: String;
test: OleVariant;
begin
//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 datathen display them
strOut:= '';
if(LEADDICOMNet1.GetUserInfoCount (LEADDICOMNet1.hPDU) > 0)then
begin
for x:= 0 to LEADDICOMNet1.GetUserInfoCount (LEADDICOMNet1.hPDU) - 1 do
begin
nType:= LEADDICOMNet1.GetUserInfoType (LEADDICOMNet1.hPDU, x);
strOut:= strOut + 'Type: ' + IntToStr(nType);
nLen:= LEADDICOMNet1.GetUserInfoLength(LEADDICOMNet1.hPDU, x);
strOut:= strOut + ' Length: ' + IntToStr(nLen);
vData:= LEADDICOMNet1.GetUserInfoData(LEADDICOMNet1.hPDU, x);
strOut:= strOut + ' Data: ';
for y:= 0 to nLen - 1 do
strOut:= strOut + Chr(Byte(vData[y]));
strOut:= strOut + Chr(13);
end;
end
else
strOut:= 'None';
ShowMessage(strOut);
//add a user info item item
strOut:= '';
test:= 'just a test';
nLen:= Length(test);
LEADDICOMNet1.AddUserInfo(LEADDICOMNet1.hPDU, 99, test, nLen);
strOut:= '';
if(LEADDICOMNet1.GetUserInfoCount (LEADDICOMNet1.hPDU) > 0)then
begin
for x:= 0 To LEADDICOMNet1.GetUserInfoCount (LEADDICOMNet1.hPDU) - 1 do
begin
nType:= LEADDICOMNet1.GetUserInfoType (LEADDICOMNet1.hPDU, x);
strOut:= strOut + 'Type: ' + IntToStr(nType);
nLen:= LEADDICOMNet1.GetUserInfoLength (LEADDICOMNet1.hPDU, x);
strOut:= strOut + ' Length: ' + IntToStr(nLen);
vData:= LEADDICOMNet1.GetUserInfoData(LEADDICOMNet1.hPDU, x);
strOut:= strOut + ' Data: ';
for y:= 0 to nLen - 1 do
strOut:= strOut + Chr(Byte(vData[y]));
strOut:= strOut + Chr(13);
end;
end
else
strOut:= 'None';
ShowMessage(strOut);
//for each user info item, change the data
test:= 'a second test';
for x:= 0 To LEADDICOMNet1.GetUserInfoCount (LEADDICOMNet1.hPDU) - 1 do
begin
nType:= LEADDICOMNet1.GetUserInfoType (LEADDICOMNet1.hPDU, x);
LEADDICOMNet1.SetUserInfo(LEADDICOMNet1.hPDU, x, nType, test, Length(test));
end;
strOut:= '';
if(LEADDICOMNet1.GetUserInfoCount (LEADDICOMNet1.hPDU) > 0)then
begin
for x:= 0 to LEADDICOMNet1.GetUserInfoCount (LEADDICOMNet1.hPDU) - 1 do
begin
nType:= LEADDICOMNet1.GetUserInfoType (LEADDICOMNet1.hPDU, x);
strOut:= strOut + 'Type: ' + IntToStr(nType);
nLen:= LEADDICOMNet1.GetUserInfoLength (LEADDICOMNet1.hPDU, x);
strOut:= strOut + ' Length: ' + IntToStr(nLen);
vData:= LEADDICOMNet1.GetUserInfoData(LEADDICOMNet1.hPDU, x);
strOut:= strOut + ' Data: ';
for y:= 0 to nLen - 1 do
strOut:= strOut + Chr(Byte(vData[y]));
strOut:= strOut + Chr(13)
end;
end
else
strOut:= 'None';
ShowMessage(strOut);
//delete the one we added
LEADDICOMNet1.DeleteUserInfo(LEADDICOMNet1.hPDU, LEADDICOMNet1.GetUserInfoCount (LEADDICOMNet1.hPDU) - 1);
LEADDICOMNet1.FreeAssociate (LEADDICOMNet1.hPDU);
end;