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

35 Visitors Online


 
...überprüfen, ob ein Drucker PostScript unterstützt?
Autor:
[ Tip ausdrucken ]  

Tip Bewertung (5):  
     


{
  That is really difficult do to if it has to work on all Windows
  platforms. The best way (no kidding) may be to ask the user which
  printer to use. What platforms do you need to support? If it is only
  Win2K (and perhaps XP) one may be able to use this (i have no
  postscript-enabled printer around to see if it works!):
}

uses
  
WinSpool, Printers;

{: Check if the currently selected printer supports postscript.
  Only applicable on Win2K/XP! }

function PrinterSupportsPostscript: Boolean;
const
  
POSTSCRIPT_PASSTHROUGH = 4115;
  POSTSCRIPT_IDENTIFY = 4117;

  Escapes: array[0..2] of Cardinal =
  (POSTSCRIPT_DATA, POSTSCRIPT_IDENTIFY, POSTSCRIPT_PASSTHROUGH);
var
  
res: Integer;
  i: Integer;
begin
  
Result := false;
  for i := Low(Escapes) to High(Escapes) do begin
    
res := ExtEscape(printer.Handle,
      QUERYESCSUPPORT,
      sizeof(Escapes[0]),
      @Escapes[i], 0, nil);
    if res <> 0 then begin
      
Result := true;
      Break;
    end;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
const
  
boolstr: array[Boolean] of string = (' not', '');
var
  
i: Integer;
  S: string;
begin
  for 
i := 0 to Printer.Printers.Count - 1 do begin
    
Printer.PrinterIndex := i;
    memo1.Lines.add(
      Format('Printer %s does%s support Postscript',
      [printer.printers[printer.printerindex],
      boolstr[PrinterSupportsPostscript]]));
  end;
end;


 

Bewerten Sie diesen Tipp:

dürftig
ausgezeichnet


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