这是我以前编写的程序NetMonitor中的一部分。
用注册表来判断机器安装了那种浏览器和路径!
//寻找浏览器
Procedure FindBrowser;
var Reg: TRegistry;
res: string;
begin
reg:=tregistry.Create;
try
reg.rootkey:=HKEY_LOCAL_MACHINE;
//判断ie是否存在
if reg.openkeyreadonly('Software/Microsoft/Windows/CurrentVersion/App Paths/IEXPLORE.EXE') then
begin
Res:=reg.readstring('');
FileDetails.AboutFile:=Res;
// IePath:=FileDetails.FilePath;
// IeName:=FileDetails.InternalName;
IeVer:=copy(FileDetails.ProductVersion,1,4);
IeExist:=True;
end;
reg.CloseKey;
//判断netscape是否存在
reg.rootkey:=HKEY_LOCAL_MACHINE;
if reg.openkeyreadonly('Software/Microsoft/Windows/CurrentVersion/App Paths/Netscape.exe') then
begin
Res:=reg.readstring('');
FileDetails.AboutFile:=Res;
// NetscapePath:=FileDetails.FilePath;
// NetscapeName:=FileDetails.InternalName;
NetscapeVer:=copy(FileDetails.ProductVersion,1,4);
NetscapeExist:=True;
end;
finally
reg.CloseKey;
reg.free;
end;
if IeExist or NetscapeExist then
begin
MonitorTimer.Enabled:=True;
IconTimer.Enabled:=True;
MailTimer.Enabled:=True;
end
else
begin
MonitorTimer.Enabled:=False;
IconTimer.Enabled:=False;
MailTimer.Enabled:=False;
end;
end;