This function retrieves the paper tray names and tray numbers from the printer designated by the printer name.
Parameters
Name | Explanation |
---|---|
PrinterName | The printer name |
BinNames | The string
containing the retrieved paper tray names By setting this to NULL (in C++Builder/Visual C++), nil (in Delphi), or vbNullString (in Visual Basic), the number of elements needed for the BinNumbers array is returned in the Return Value. |
BinNumbers | The array containing the
retrieved paper tray numbers (1)In C++Builder/Visual C++, pass the pointer to the first element of the array (2)In Delphi, for example, Bnum: array [0..2] of Word then set Bnum[0] (3)In Visual Basic, Dim Bnum(0 To 2) As Integer then set Bnum(0) |
Return Value
Returns the number of retrieved items. Returns 0 if unsuccessful.
Explanation
The IKEnumPaperBins function retrieves the paper tray names and tray numbers from the printer designated by the printer name.
To retrieve the number of elements in the BinNumbers array (in the Return Value), set BinNames to NULL (in C++Builder/Visual C++), nil (in Delphi), or vbNullString (in Visual Basic). BinNames must be allocated with a memory size of the number of elements X (24 + 1)+ 1. Note that the IKPrintGetArrayNum function can also be used to retrieve this. The BinNames string will be returned as "xxxxx,xxxxx,xxxxx,¥¥¥¥¥¥¥¥," (delimited by commas and ends with a comma).
Sample code:
(1)C++Builder/Visual C++
int Size;
TCHAR *BinNames;
LPWORD BinNumbers;
Size = IKEnumPaperBins("EPSON LP-8200C", NULL, NULL);
if (Size < 1) return;
BinNames = (TCHAR *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, Size * (sizeof(TCHAR) * (24 + 1) + sizeof(TCHAR);
BinNumbers = (LPWORD)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WORD) * Size);
__try {
IKEnumPaperBins("EPSON LP-8200C", BinNames, BinNumbers);
// various programming code
..................
..................
} __finally {
HeapFree(GetProcessHeap(), 0, BinNames);
HeapFree(GetProcessHeap(), 0, BinNumbers);
}
(2)Delphi
Size: Integer;
BinNames: PChar;
BinNumbers: array of Word;
Size := IKEnumPaperBins('EPSON LP-8200C', nil, PWord(nil)^);
if Size < 1 then Exit;
GetMem(BinNames, Size * (SizeOf(Char) * (24 + 1)) + SizeOf(Char));
SetLength(BinNumbers, Size);
try
IKEnumPaperBins('EPSON LP-8200C', BinNames, BinNumbers[0]);
// various programming code
......................
.....................
finally
FreeMem(BinNames);
end;
(3)Visual Basic
Dim Size As Long
Dim BinNames As String * 1024
Dim BinNumbers() As Integer
Size = IKPrintGetArrayNum("EPSON LP-8200C", 1)
If Size < 1 Then Exit Sub
ReDim BinNumbers(Size)
Call IKEnumPaperBins("EPSON LP-8200C", BinNames, BinNumbers(0))
' various programming code
.....................
.....................