uses Registry, Windows, ShellAPI;
function GetDefaultBrowser:
String;
var
Browser:
string;
begin
Browser := '
';
with TRegistry.Create(KEY_READ)
do
try
RootKey := HKEY_CLASSES_ROOT;
Access := KEY_QUERY_VALUE;
if OpenKey('
\http\shell\open\command', False)
then
Browser := ReadString('
') ;
CloseKey;
finally
Free;
end;
if Browser <> '
'
then
begin
Browser := Copy(Browser, Pos('
"', Browser) + 1, Length(Browser)) ;
Browser := Copy(Browser, 1, Pos('
"', Browser) - 1) ;
end;
Result := Browser;
end;
function NavigateTo(
const aURL:
String): Integer;
var
DefaultBrowser:
String;
begin
DefaultBrowser := GetDefaultBrowser;
if (DefaultBrowser <> '
')
then
Result := ShellExecute(0, '
open', PChar(DefaultBrowser),
PChar(aURL),
nil, SW_SHOWNORMAL)
else
Result := ShellExecute(0, '
open', PChar(aURL),
nil,
nil, SW_SHOWNORMAL);
end;