This method retrieves the paper tray names and tray numbers from the printer designated by the printer name.
Parameters
Name | Explanation |
---|---|
BinNames | The string containing the retrieved paper tray names |
BinNumbers | The array containing the retrieved paper tray numbers
(1)In Visual C++, pass the pointer to the first element of the array (2)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 EnumPaperBins method retrieves the supported paper tray names and tray numbers from the printer designated by the printer name. If you need to know the number of elements in the array, the GetArrayNum method can be used to retrieve this. The BinNames string will be returned as "xxxxx,xxxxx,xxxxx,¥¥¥¥¥¥¥¥," (delimited by commas and ends with a comma).
For scripting languages and other programs that require variant types, please refer to the EnumPaperBinsVariant method.
Note: In VB.NET and C#.NET, you cannot retrieve the string for BinNames. Use InvokeMembers instead. For details, please see the code example below.
Sample code:
Visual Basic
Dim Size As Long
Dim BinNames As String
Dim BinNumbers() As Integer
Dim Ret As Long
Size = ImageKit1.PrintDraw.GetArrayNum(1)
If Size < 1 Then Exit Sub
ReDim BinNumbers(Size)
Ret = ImageKit1.PrintDraw.EnumPaperBins(BinNames, BinNumbers(0))
' various programming code
.........
Visual C++
long Size;
BSTR BinNames;
short *BinNumbers;
ImageKit1.GetPrintDraw().SetPrinterName("EPSON LP-8200C");
Size = ImageKit1.GetPrintDraw().GetArrayNum(1);
if (Size < 1) return;
BinNumbers = (short *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(short) * Size);
__try {
ImageKit1->PrintDraw->EnumPaperBins(&BinNames, BinNumbers);
// various programming code
..........
} __finally {
HeapFree(GetProcessHeap(), 0, BinNumbers);
}
Visual Basic.NET
ImageKit1.PrintDraw.PrinterName = "EPSON LP-8200C"
Dim t As Type = Type.GetTypeFromProgID("ImageKit8.PrintDraw")
Dim p As New System.Reflection.ParameterModifier(2)
p(0) = True
p(1) = True
Dim mods() As System.Reflection.ParameterModifier = {p}
Dim args() As Object = {"", Nothing}
Dim Size As Long = CType(t.InvokeMember("EnumPaperBinsVariant", System.Reflection.BindingFlags.InvokeMethod, Nothing, ImageKit1.PrintDraw, args, mods, Nothing, Nothing), Integer)
If Size < 1 Then Exit Sub
Dim BinNames As String = CType(args(0), String)
Dim BinNumbers As Short() = CType(args(1), Short())
'..........
Visual C#.NET
ImageKit1.PrintDraw.PrinterName = "EPSON LP-8200C";
Type t = Type.GetTypeFromProgID("ImageKit8.PrintDraw");
System.Reflection.ParameterModifier p = new System.Reflection.ParameterModifier(2);
p[0] = true;
p[1] = true;
System.Reflection.ParameterModifier[] mods = {p};
object[] args = { "", null };
int Size = (int)t.InvokeMember("EnumPaperBinsVariant", System.Reflection.BindingFlags.InvokeMethod, null, ImageKit1.PrintDraw, args, mods, null, null);
if (Size < 1) return;
string BinNames = (string)args[0];
short[] BinNums = (short[])args[1];
//..........