ConnaĆ®tre la résolution de l'imprimante par défaut

uses Printers;

procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.Caption := IntToStr(GetDeviceCaps(Printer.Handle, LOGPIXELSX)) +
' x '+IntToStr(GetDeviceCaps(Printer.Handle, LOGPIXELSY))+
' DPI (dots per inch)';
end;

Truc|ConnaƮtre la version du driver de l'imprimante

uses Printers, Winspool;


procedure TForm1.FormCreate(Sender: TObject);
begin
ComboBox1.Items.Assign(Printer.Printers);
end;


procedure TForm1.ComboBox1Change(Sender: TObject);
var
hPrinter: THandle;
PrtName: String;
DriverInfo: PDriverInfo2;
dwNeeded: DWord;
begin
Memo1.Clear;
PrtName := Combobox1.Text;
OpenPrinter(PChar(PrtName) , hPrinter, nil);
GetPrinterDriver(hPrinter, nil, 2, DriverInfo, 0, dwNeeded);
GetMem(DriverInfo, dwNeeded);
if GetPrinterDriver(hPrinter, nil, 2, DriverInfo, dwNeeded, dwNeeded) then
begin
// The driver version
Memo1.Lines.Add('Version: '+IntToStr(DriverInfo.cVersion));
Memo1.Lines.Add(StrPas(DriverInfo.pName));
Memo1.Lines.Add(StrPas(DriverInfo.pEnvironment));
Memo1.Lines.Add(StrPas(DriverInfo.pDriverPath));
Memo1.Lines.Add(StrPas(DriverInfo.pDataFile));
Memo1.Lines.Add(StrPas(DriverInfo.pConfigFile));
end
else
Memo1.Lines.Add('No Info needed = ' + IntToStr(dwNeeded));

ClosePrinter(hPrinter);
FreeMem(DriverInfo);
end;
Ajouter un commentaire
Pseudo
Adresse email
Site internet (optionnel)
Votre commentaire
Fiche de l'article
Mise a jour30/11/2001
VisualisationVu 909 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