This function retrieves the paper tray names and tray numbers from the printer designated by the printer name.

[C++Builder]     int IKEnumPaperBins(LPCSTR PrinterName, LPSTR BinNames, LPWORD BinNumbers);
[Delphi]         function IKEnumPaperBins(PrinterName, BinNames: PChar; var BinNumbers: Word): Integer;

Parameters

Name Explanation
PrinterName The printer name
The string containing the retrieved paper tray names
By setting this to NULL (in C++Builder) or nil (in Delphi), 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, 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]

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) or nil (in Delphi). 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:

In C++Builder

    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);
    }

In 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;

 

The ImageKit10 VCL is a product created by Newtone Corporation