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