虽然aimingoo的方法不错,但也只是对IE有效。
如果想对其他浏览器也有效呢??
试试这个:(可惜你已分了分数。。。。)
function findBrowser : string;
var
fileType : string;
browserPath : string;
i : integer;
const
extensionCount = 4;
htmlextensions : array[0..extensionCount-1] of string = ('.html','.htm','.shtml','.shtm');
begin
with TRegistry.Create do
try
RootKey := HKEY_CLASSES_ROOT;
browserPath:='';
i:=0;
while (length(browserPath) = 0) and (i <= extensionCount) do
begin
if OpenKey ('/' + htmlextensions, false) = true then
begin
fileType := ReadString('');
if length(fileType) <> 0 then
if OpenKey ('/' + fileType + '/shell/open/command', false) = true then
browserPath := ReadString('');
end;
inc(i);
end; //end while
CloseKey;
finally
Free;
end;
while pos(' -nohome', browserpath) <> 0 do browserpath := Stringreplace(browserpath, ' -nohome', '',[rfreplaceall]);
while pos('%1', browserpath) <> 0 do browserpath := Stringreplace(browserpath, '%1', '',[rfreplaceall]);
while pos('"', browserpath) <> 0 do browserpath := Stringreplace(browserpath, '"', '',[rfreplaceall]);
result := trim(browserpath);
end;