最近遇到的问题,用默认浏览器打开文件的时候,在不同默认浏览器下效果不一致,尤其是ie6和其他有选项卡的浏览器,现在采用的处理方法是读取注册表,根据不同的浏览器及其版本采用不同的打开方式。 {----------------------------------------------------------------------------- 单元名: OpenHtml 作者: zhuy 日期: 2009.03.13 备注: 默认浏览器打开新网页 审核 -----------------------------------------------------------------------------} unit GCLOpenHtml; interface uses SysUtils, ShellAPI, Registry, Windows; function BrowseURL(const URL: string) : boolean; implementation function BrowseURL(const URL: string) : boolean; var sBrowser, sVersion: string; begin Result := False; sBrowser := ''; with TRegistry.Create do try RootKey := HKEY_CLASSES_ROOT; Access := KEY_QUERY_VALUE; if OpenKey('/http/shell/open/command', False) then sBrowser := ReadString('') ; CloseKey; finally Free; end; if sBrowser <> '' then begin sBrowser := Copy(sBrowser, Pos('"', sBrowser) + 1, Length(sBrowser)) ; sBrowser := Copy(sBrowser, 1, Pos('"', sBrowser) - 1); end; if (Pos(UpperCase('iexplore'),UpperCase(sBrowser)) > 0) then begin //判断IE版本 with TRegistry.Create do try RootKey := HKEY_LOCAL_MACHINE; if OpenKey('/Software/Microsoft/Internet Explorer/Version Vector', False) then begin sVersion := ReadString('IE'); if StrToFloat(sVersion) < 7 then Result := True; CloseKey; end; finally Free; end; end; if Result then ShellExecute(0, PChar('open'), PChar(sBrowser), PChar(URL), nil, SW_SHOW) else ShellExecute(0, PChar('open'), PChar(URL), PChar(''), PChar(''), SW_SHOW); end; end.