...retrieve the Port of a given Printer (W2K, XP)?
|
Autor:
jahuer1 |
[ Print tip
] | | |
// 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;
|