16,748
社区成员
发帖
与我相关
我的任务
分享
function BrowseURL(const URL: string) : boolean;
var
Browser: string;
begin
Result := True;
Browser := '';
with TRegistry.Create do
try
RootKey := HKEY_CLASSES_ROOT;
Access := KEY_QUERY_VALUE;
if OpenKey('\htmlfile\shell\open\command', False) then
Browser := ReadString('') ;
CloseKey;
finally
Free;
end;
if Browser = '' then
begin
Result := False;
Exit;
end;
if RightStr(Browser,1)<> '"' then
begin
// 这个if是为遨游旧版写的补丁 因为遨游旧版在注册表里生成的代码没有双引号 导致无法打开
Browser:= '"' + Browser;
Browser:= Browser + '"';
Browser:= StringReplace(Browser,' %1','" "%1',[rfReplaceAll]);
//Showmessage(Browser); 测试用
end;
//遨游补丁结束
Browser := Copy(Browser, Pos('"', Browser) + 1, Length(Browser)) ;
Browser := Copy(Browser, 1, Pos('"', Browser) - 1) ;
ShellExecute(0, 'open', PChar(Browser), PChar(URL), nil, SW_SHOW) ;
end;
//这是从右边取 顺便发上来
function RightStr (Const Str: String; Size: Word): String;
begin
if Size > Length(Str) then Size := Length(Str) ;
RightStr := Copy(Str, Length(Str)-Size+1, Size)
end;