was ist neu ¦  programmier tips ¦  indy artikel ¦  intraweb artikel ¦  informationen ¦  links ¦  interviews
 sonstiges ¦  tutorials ¦  Add&Win Gewinnspiel

Tips (1541)

Dateien (137)
Datenbanken (90)
Drucken (35)
Grafik (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Mathematik (76)
Multimedia (45)
Oberfläche (107)
Objekte/
ActiveX (51)

OpenTools API (3)
Sonstiges (126)
Strings (83)
System (266)
VCL (242)

Tips sortiert nach
Komponente


Tip suchen

Tip hinzufügen

Add&Win Gewinnspiel

Werbung

38 Visitors Online


 
...herausfinden, ob ein Drucker ein Matrix oder Laser oder InkJet Drucker ist?
Autor: Sasa Zeman
Homepage: www.szutils.net
[ Tip ausdrucken ]  

Tip Bewertung (16):  
     


{$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.


 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners