Lister les formats de papier supportés par l'imprimante

Uses
Printers, WinSpool;

procedure GetPapernames(sl: TStrings);
type
TPaperName = array [0..63] of char;
TPaperNameArray = array [1..High(word) 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; // Standard printer
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);
sl.Clear;
for i := 1 to numPaperformats do sl.add(pPaperformats^[i]);
finally
FreeMem(pPaperformats);
end;
end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
GetPapernames(memo1.lines);
end;
Ajouter un commentaire
Pseudo
Adresse email
Site internet (optionnel)
Votre commentaire
Fiche de l'article
Mise a jour02/04/2002
VisualisationVu 838 fois
PublicInternaute zz
CategorieDelphi - Trucs et astuces - Systeme
Auteur de l'article
SwissDelphiCenter SwissDelphiCenter
connecté le 02/11/2011
329 articles dans la section
Contacter l'auteur