whats new ¦  programming tips ¦  indy articles ¦  intraweb articles ¦  informations ¦  links ¦  interviews
 misc ¦  tutorials ¦  Add&Win Game

Tips (1541)

Database (90)
Files (137)
Forms (107)
Graphic (114)
IDE (21)
Indy (5)
Internet / LAN (130)
IntraWeb (0)
Math (76)
Misc (126)
Multimedia (45)
Objects/
ActiveX (51)

OpenTools API (3)
Printing (35)
Strings (83)
System (266)
VCL (242)

Top15

Tips sort by
component


Search Tip

Add new Tip

Add&Win Game

Advertising

23 Visitors Online


 
...retrieve the Port of a given Printer (W2K, XP)?
Autor: jahuer1
[ Print tip ]  

Tip Rating (38):  
     




// Mit bestem Dank an "Blitz" für die Grundidee!

uses
  
Registry;

//...

function Get_Printerport(Printername: string): string;
var
  
Reg: TRegistry;
  p: Integer;
begin
  
Reg := TRegistry.Create;
  with Reg do
  begin
    
RootKey := HKEY_CURRENT_USER;
    if OpenKey('\Software\Microsoft\Windows NT\CurrentVersion\Devices\', True) then
    begin
      if 
ValueExists(Printername) then
      begin
        
// Im reg Key steht so etwas wie   "winspool,LPT1:"
        // The reg Key value may look like "winspool,LPT1:"
        
Result := ReadString(Printername);
        p      := Pos(',', Result);
        Result := Copy(Result, p + 1,Length(Result) - p);
      end;
    end;
    CloseKey;
  end;
end;


 

Rate this tip:

poor
very good


Copyright © by SwissDelphiCenter.ch
All trademarks are the sole property of their respective owners