Type
TBinName =
Array [0..23]
of Char;
TBinNameArray =
Array [1..High(Integer)
div Sizeof( TBinName )]
of
TBinName;
PBinnameArray = ^TBinNameArray;
TBinArray =
Array [1..High(Integer)
div Sizeof(Word)]
of Word;
PBinArray = ^TBinArray;
procedure GetPrnBinNames(BinList: TStrings; WithNrInText: boolean);
Var
Device, Driver, Port:
Array [0..255]
of Char;
hDevMode: THandle;
i, numBinNames, numBins, temp: Integer;
pBinNames: PBinnameArray;
pBins: PBinArray;
begin
// Printer.PrinterIndex := -1;
Printer.PrinterIndex := Printer.PrinterIndex;
// added
Printer.GetPrinter(Device, Driver, Port, hDevmode);
numBinNames := Winspool.DeviceCapabilities(Device, Port, DC_BINNAMES,
Nil,
Nil);
numBins := Winspool.DeviceCapabilities(Device, Port, DC_BINS,
Nil,
Nil);
if (numBins <> numBinNames)
then begin
raise Exception.Create('
DeviceCapabilities: unterschiedliche Anzahl und
Namen!');
end;
// if
if numBinNames > 0
then begin
// pBins := nil;
GetMem(pBinNames, numBinNames * Sizeof( TBinname));
GetMem(pBins, numBins * Sizeof(Word));
try
Winspool.DeviceCapabilities(Device, Port, DC_BINNAMES, Pchar(pBinNames),
nil);
Winspool.DeviceCapabilities(Device, Port, DC_BINS, Pchar(pBins),
nil);
BinList.Clear();
for i:= 1
to numBinNames
do begin
temp := pBins^[i];
if (WithNrInText)
then BinList.AddObject( pBinNames^[i]+'
'+IntToStr(temp), TObject(temp))
else BinList.AddObject( pBinNames^[i], TObject(temp));
end;
finally
FreeMem(pBinNames);
if (pBins <>
nil)
then FreeMem(pBins);
end;
end;
// if
end;