• Delphi WebBrowser内核版本修改D7


      private
        { Private declarations }
      public
        { Public declarations }
        function WriteAppNameToReg:Boolean;
        function GetIEVersionStr: string;
        function IsWin64:Boolean;
    
    var
      Form3: TForm3;
    
    implementation
    
    function TForm3.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;
    function TForm3.GetIEVersionStr: string;   //获取IE版本
    var
     Reg: TRegistry; // registry access object
    begin
     Result := '';
     Reg := TRegistry.Create;
     try
        Reg.RootKey := Windows.HKEY_LOCAL_MACHINE;
     if Reg.OpenKeyReadOnly('SoftwareMicrosoftInternet 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 TForm3.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:='SOFTWAREMicrosoftInternet ExplorerMAINFeatureControlFEATURE_BROWSER_EMULATION';
            if isWin64 then
            sPath:='SOFTWAREWow6432NodeMicrosoftInternet ExplorerMAINFeatureControlFEATURE_BROWSER_EMULATION';
            if reg.OpenKey(sPath,True) then
            begin
             sAppName:=ExtractFileName(Application.ExeName);
             Sver:=GetIEVersionStr;
             lenver:=StrToInt( Copy(Sver,1,Pos('.',Sver)-1) );
              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;
    end;
    procedure TForm3.FormCreate(Sender: TObject);
    begin
    WriteAppNameToReg;
    end;
  • 相关阅读:
    移动银盘 文件或目录损坏且无法读取 提示格式化
    error: Some data has already been output, can't send PDF file
    php pdf english french duch……应用攻略,ufpdf
    photoshop cs4 多语言
    c++常用知识小结
    简单的排序
    内存对齐
    socket网络编程常用的结构及函数小结
    字符和字符串处理小结
    几个小程序
  • 原文地址:https://www.cnblogs.com/windson/p/12521317.html
Copyright © 2020-2023  润新知