unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, Printers, WinSpool;
type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
type
TPaperName = array [0..63] of Char;
TPaperNameArray = array [1..High(Cardinal) div Sizeof( TPaperName )] of TPaperName;
PPapernameArray = ^TPaperNameArray;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
Device, Driver, Port: array [0..255] of Char;
hDevMode: THandle;
i, numPaperformats: Integer;
pPaperFormats: PPapernameArray;
begin
Printer.PrinterIndex := -1; // ±âº»ÇÁ¸°ÅÍ ÁöÁ¤
Printer.GetPrinter(Device, Driver, Port, hDevmode);
numPaperformats := WinSpool.DeviceCapabilities(Device, Port, DC_PAPERNAMES, nil, nil);
if numPaperformats > 0 then
begin
GetMem(pPaperformats, numPaperformats * Sizeof(TPapername));
try
WinSpool.DeviceCapabilities(Device,Port, DC_PAPERNAMES, Pchar(pPaperFormats), nil);
Memo1.Clear;
for i := 1 to numPaperformats do
Memo1.Lines.Add(pPaperformats^[i]);
finally
FreeMem(pPaperformats);
end;
end;
end;
end. |
|