uses WinSpool, Printers;
procedure Papierformate(sl: TStrings);
var
h: THandle;
i, count: Integer;
Papierformat, Papier: PChar;
Device, Driver, Port: array[0..255] of Char;
begin
sl.BeginUpdate;
sl.Clear;
Printer.GetPrinter(Device, Driver, Port, h);
count := DeviceCapabilities(Device, Port, DC_PAPERNAMES, nil, nil);
if count > 0 then begin
GetMem(Papierformat, count * 64);
try
DeviceCapabilities(Device, Port, DC_PAPERNAMES, Papierformat, nil);
Papier := Papierformat;
for i := 0 to count - 1 do begin
sl.add(Papier);
inc(Papier, 64);
end;
finally
FreeMem(Papierformat);
end;
end;
sl.endupdate;
end;
// Beispielaufruf
procedure TForm1.Button1Click(Sender: TObject);
begin
if Printdialog1.execute then
Papierformate(Memo1.Lines);
end;