Delphi WebBrowser 组件关系图
TWebBrowser = class(TCustomWebBrowser)
核心点在于注册表:HKEY_CURRENT_USER > Software > Microsoft > Internet Explorer > Main > FeatureControl > FEATURE_BROWSER_EMULATION
位置,详见代码实现:
unit FormMain; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.OleCtrls, SHDocVw, System.Win.Registry, Vcl.ExtCtrls; type TfrmMain = class(TForm) ... procedure FormCreate(Sender: TObject); procedure FormResize(Sender: TObject); private { Private declarations } procedure SetPermissions(); public { Public declarations } end; .... procedure TForm1.FormCreate(Sender: TObject); begin {$IFDEF MSWINDOWS} SetPermissions; {$ENDIF} end; {$IFDEF MSWINDOWS} procedure TfrmMain.SetPermissions; const cHomePath = 'SOFTWARE'; cFeatureBrowserEmulation = 'Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION\'; cIE11 = 11001; var Reg: TRegIniFile; sKey: string; begin sKey := ExtractFileName(ParamStr(0)); Reg := TRegIniFile.Create(cHomePath); try if Reg.OpenKey(cFeatureBrowserEmulation, True) and not(TRegistry(Reg).KeyExists(sKey) and (TRegistry(Reg).ReadInteger(sKey) = cIE11)) then TRegistry(Reg).WriteInteger(sKey, cIE11); finally Reg.Free; end; end; {$ENDIF} ... end.