请教:如何获取打印机的分辨率?
GetDeviceCaps(printerHandle?,LOGPIXELSX);中
第一个参数怎么定义?

解决方案 »

  1.   

    第一个参数是一个指针,指向打印机的设备描述结构device context(DC).
      

  2.   

    指向打印机的设备 (Printer.handle)unit PrinterDpi;interfaceuses
      Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,printers,
      StdCtrls;type
      TForm1 = class(TForm)
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.DFM}procedure TForm1.Button1Click(Sender: TObject);
    var
      ppix : Integer;
    begin
      ppix := GetDeviceCaps(Printer.Handle, logPixelsX);
      showmessage('x-dpi:'+floattostr(ppix));
      ppix := GetDeviceCaps(Printer.Handle, logPixelsY);
      showmessage('y-dpi:' +floattostr(ppix));
    end;end.