首页  编辑  

当前打印机的纸张大小(A3还是A4等等)

Tags: /超级猛料/Print.打印/   Date Created:

]、。·ˉˇ¨〃々—~‖…’”〕〉》」』〗】∶!"'),.:;?]` procedure TForm1.Button1Click(Sender: TObject);

var

 Device: Array[0..(cchDeviceName -1)] of char;

 Driver: Array[0..(MAX_PATH -1)] of char;

 Port: Array[0..32] of char;

 HDMode : THandle;

 PDMode: PDevMode;

begin

 Printer.PrinterIndex :=  Printer.PrinterIndex ;

 Printer.GetPrinter(Device,Driver,Port,HDMode);

 if HDMode <> 0 then

 begin

   PDMode := GlobalLock(HDMode);

   if PDMode <> nil then

   begin

     case pDMode.dmPaperSize of

       DMPAPER_USER: showmessage('纸张类型:自定义');

       DMPAPER_A3: showmessage('纸张类型:A3');

       DMPAPER_A4: showmessage('纸张类型:A4');

       DMPAPER_A5: showmessage('纸张类型:A5');

       DMPAPER_B4: showmessage('纸张类型:B4');

       DMPAPER_B5: showmessage('纸张类型:B5');

       else showmessage('纸张类型:其它');

     end;

     GlobalUnLock(HDMode);

     Printer.PrinterIndex := Printer.PrinterIndex;

   end;

 end;

end;