首页  编辑  

检测打印机是点阵还是激光打印机

Tags: /超级猛料/Print.打印/   Date Created:

检测打印机是点阵还是激光打印机

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;