Author: Tomas Rutkauskas How I can select the printer's papersource through code? How I can read the printer default setting papersource in my Delphi program? Answer: 1 { ... } 2 var 3 aDrvName, aPrtName, aPortName: array[0..127] of Char; 4 aDeviceMode: THandle; 5 PDevMode: ^TDevMode; 6 i: Integer; 7 begin 8 with Printer do 9 begin 10 GetPrinter(aDrvName, aPrtName, aPortName, aDeviceMode); 11 PDevMode := GlobalLock(aDeviceMode); 12 try 13 if PDevMode^.dmPaperSize = DMPAPER_A4 then 14 ShowMessage('A4') 15 else if PDevMode^.dmPaperSize = DMPAPER_A3 then 16 ShowMessage('A3') 17 else 18 begin 19 ShowMessage('Size not supported!' + #13 + 'Resetting papersize to A4'); 20 PDevMode^.dmPaperSize := DMPAPER_A4; 21 end; 22 finally 23 GlobalUnlock(aDeviceMode); 24 end; 25 end; 26 end;