whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

32 Visitors Online


 
...list all paper names supported by a printer?
Autor: P. Below
Homepage: http://www.teamb.com
[ Print tip ]  

Tip Rating (17):  
     




uses
  
Printers, WinSpool;

procedure GetPapernames(sl: TStrings);
type
  
TPaperName      = array [0..63] of Char;
  TPaperNameArray = array [1..High(Word) div SizeOf(TPaperName)] of TPaperName;
  PPapernameArray = ^TPaperNameArray;
var
  
Device, Driver, Port: array [0..255] of Char;
  hDevMode: THandle;
  i, numPaperformats: Integer;
  pPaperFormats: PPapernameArray;
begin
  
Printer.PrinterIndex := -1; // Standard printer
  
Printer.GetPrinter(Device, Driver, Port, hDevmode);
  numPaperformats := WinSpool.DeviceCapabilities(Device, Port, DC_PAPERNAMES, nilnil);
  if numPaperformats  0 then 
  begin
    
GetMem(pPaperformats, numPaperformats * SizeOf(TPapername));
    try
      
WinSpool.DeviceCapabilities(Device, Port, DC_PAPERNAMES,
        PChar(pPaperFormats), nil);
      sl.Clear;
      for i := 1 to numPaperformats do sl.Add(pPaperformats^[i]);
    finally
      
FreeMem(pPaperformats);
    end;
  end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  
GetPapernames(memo1.Lines);
end;


 

Rate this tip:

poor
very good


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