Вот пример, выводящий список форматов бумаги для принтера, установленного по умолчанию:
procedure TForm1.Button2Click(Sender: TObject); Type TPaperName = Array [0..63] of Char; TPaperNameArray = Array [1..High(Cardinal) div Sizeof( TPaperName )] of TPaperName; PPapernameArray = ^TPaperNameArray; Var Device, Driver, Port: Array [0..255] of Char; hDevMode: THandle; i, numPaperformats: Integer; pPaperFormats: PPapernameArray; begin Printer.PrinterIndex := -1; Printer.GetPrinter(Device, Driver, Port, hDevmode); numPaperformats := WinSpool.DeviceCapabilities( Device, Port, DC_PAPERNAMES, Nil, Nil ); If numPaperformats > 0 Then Begin GetMem( pPaperformats, numPaperformats * Sizeof( TPapername )); try WinSpool.DeviceCapabilities( Device, Port, DC_PAPERNAMES, Pchar( pPaperFormats ), Nil); memo1.clear; For i:= 1 To numPaperformats Do memo1.lines.add( pPaperformats^[i] ); finally FreeMem( pPaperformats ); end; End; End; |
[000095]