...herausfinden, ob ein Drucker ein Matrix oder Laser oder InkJet Drucker ist?
Autor: Sasa Zeman
{$APPTYPE CONSOLE}
uses Windows, Printers, WinSpool, Variants;
{
Using only API calls, determinate which type is the active printer:
Dot-Matrix or Laser (or InkJet)
This example is distributed "AS IS", WITHOUT WARRANTY OF ANY KIND,
either express or implied. You use it at your own risk!
}
function IsPrinterMatrix: Boolean;
var
DeviceMode: THandle;
Device, Driver, Port: array [0..79] of Char;
pDevice, pDriver, pPort: PChar;
begin
// Determinate that active printer is a Dot-Marix
Result:= False;
pDevice := @Device;
pDriver := @Driver;
pPort := @Port;
Device := #0;
Driver := #0;
Port := #0;
Printer.GetPrinter(pDevice, pDriver, pPort, DeviceMode);
// Printer can be dot-matrix when number of colors is maximum 16
// and when printer is capable to print only for TRUETYPE
// fonts as graphics (dot-matrix and PCL printers are capable for that).
if (GetDeviceCaps(Printer.Handle,NUMCOLORS)<=16) and
(DeviceCapabilities(pDevice, pPort,DC_TRUETYPE,nil,nil) = DCTT_BITMAP)
then
Result := True;
end;
begin
writeln ('Active printer is ', Printer.Printers[Printer.PrinterIndex]);
if IsPrinterMatrix then
writeln('This is a Dot-Matrix printer')
else
writeln('This is a LaserJet or InkJet printer');
end.
printed from
www.swissdelphicenter.ch
developers knowledge base