this slowpoke moves

Investigate Printer is Matrix or LaserJet

uses Printers, WinSpool

//

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;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Label1.Caption := 'Active printer is :' + Printer.Printers[Printer.PrinterIndex];

  if IsPrinterMatrix then
    Label1.Caption := ('This is a Dot-Matrix printer')
  else
    Label1.Caption := ('This is a LaserJet or InkJet printer');
end;

Keine Kommentare:

Kommentar veröffentlichen

Beliebte Posts

Translate