Delphi TWebBrowser 内核版本修改
WebBrowser的默认内核是IE的
改变内核版本的操作:
1、在开始菜单内输入“regedit.exe”,进入注册表编辑器
2、找到注册表项:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION
在右侧空白区域内单击鼠标右键,点击[新建]→[DWORD(32-位)值]
新建的项取名为 你的执行文件名称(例如:MyApplication.exe),编辑值时,选择基数“十进制”,填写数值数据,这里填写11000(IE11)
不同IE版本所对应的DWORD值:
微软地址:https://msdn.microsoft.com/en-us/library/ee330730(v=vs.85).aspx#browser_emulation
原文:https://www.cnblogs.com/doscanner/p/5611434.html
有时间再补充博客,写一个Delphi 版的自动修改代码,以下代码适合Delphi7
function TFrom1.WriteAppNameToReg:Boolean; //写入到注册表
var
reg:TRegistry;
sPath,sAppName:String;
Sver:string;
lenver:Integer;
begin
Result:=True;
reg:=TRegistry.Create;
try
reg.RootKey:=HKEY_LOCAL_MACHINE;
sPath:='SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION';
if isWin64 then
sPath:='SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION';
if reg.OpenKey(sPath,True) then
begin
sAppName:=ExtractFileName(Application.ExeName);
Sver:=GetIEVersionStr; lenver:=StrToInt( Copy(Sver,1,Pos('.',Sver)-1) );
//lenver:=StrToInt(leftstr(Sver, Pos('.',Sver)-1));
// if not reg.ValueExists(sAppName)then
if lenver<=7 then
reg.WriteInteger(sAppName,7000)
else
if lenver=8 then
begin
reg.WriteInteger(sAppName,8000)
end
else
if lenver=9 then
begin
reg.WriteInteger(sAppName,9000)
end
else
if lenver=10 then
begin
reg.WriteInteger(sAppName,10000)
end
else
if lenver=11 then
begin
reg.WriteInteger(sAppName,11001)
end;
end;
reg.CloseKey;
finally
FreeAndNil(reg);
end;
function TFrom1.GetIEVersionStr: string; //获取IE版本
var
Reg: TRegistry; // registry access object
begin
Result := '';
Reg := TRegistry.Create;
try
Reg.RootKey := Windows.HKEY_LOCAL_MACHINE;
if Reg.OpenKeyReadOnly('Software\Microsoft\Internet Explorer') then
begin
//这儿新版本IE的取值位置不同所以要判断 if Reg.ValueExists('svcVersion') then
Result := Reg.ReadString('svcVersion')
else
if Reg.ValueExists('Version') then
Result := Reg.ReadString('Version');
end;
finally
Reg.Free;
end;
end;
function TForm1.IsWin64:Boolean; // 判断系统
var
Kernel32Handle:THandle;
IsWow64Process: function(Handle:Windows.THandle;var Res:Windows.BOOL):Windows.BOOL;stdcall;
GetNativeSystemInfo:procedure(var lpSystemInfo:TSystemInfo);stdcall;
isWoW64: Bool;
SystemInfo: TSystemInfo;
const
PROCESSOR_ARCHITECTURE_AMD64=9;
PROCESSOR_ARCHITECTURE_IA64=6;
begin
Kernel32Handle:=GetModuleHandle('KERNEL32.DLL');
if Kernel32Handle=0 then
Kernel32Handle:=LoadLibrary('KERNEL32.DLL');
if Kernel32Handle<>0 then
begin
IsWOW64Process:=GetProcAddress(Kernel32Handle,'IsWow64Process');
GetNativeSystemInfo:=GetProcAddress(Kernel32Handle,'GetNativeSystemInfo');
if Assigned(IsWow64Process) then
begin
IsWow64Process(GetCurrentProcess,isWoW64);
Result:=isWoW64 and Assigned(GetNativeSystemInfo);
if Result then
begin
GetNativeSystemInfo(SystemInfo);
Result:=(SystemInfo.wProcessorArchitecture=PROCESSOR_ARCHITECTURE_AMD64)or
(SystemInfo.wProcessorArchitecture=PROCESSOR_ARCHITECTURE_IA64);
end;
end
else
Result:=False;
end
else
Result:=False;
end;
创建时间:2020.03.03 更新时间:2020.11.19
|
请发表评论