Get paper source

Posted in System info

Use DevMode structure to detect paper source.

uses Printers;
...
procedure TForm1.Button2Click(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.GetPrinter(Device, Driver, Port, hDMode);
  if (hDMode<>0) then
  begin
    pDMode:=GlobalLock(hDMode);
    if pDMode<>nil then
    begin
      if (pDMode^.dmDefaultSource=7) then
        Label1.Caption:='Paper source - auto';
      if (pDMode^.dmDefaultSource=4) then
        Label1.Caption:='Paper source - manual';
    end;
  end;
end;