Impressao - obter a porta da impressora a partir do registro

Top  Previous  Next

uses registry; 

 

function Get_Printerport(Printername: String): string; 

var 

  Reg: TRegistry; 

begin 

  Reg := TRegistry.Create

  with Reg do 

  begin 

    RootKey := HKEY_LOCAL_MACHINE; 

     if OpenKey('\System\CurrentControlSet\Control\Print\printers\' + Printername + '\', True) then 

       if ValueExists('port') then 

       Result := Readstring('port'); 

      CloseKey; 

  end

end