CEF4Delphi 常用設置


CEF4Delphi 是由 SalvadorDíazFau 創建的一個開源項目,用於在基於Delphi的應用程序中嵌入基於Chromium的瀏覽器。

CEF4Delphi 基於Henri Gourvest 的 DCEF3。DCEF3的原始許可證仍適用於CEF4Delphi。閱讀任何* .pas文件的第一行中的許可條款。

CEF4Delphi 使用CEF 3.3325.1756.g6d8faa4,其中包 Chromium 65.0.3325.181。CEF4Delphi使用的CEF3二進制文件可以在spotify下載:

32bit -> http://opensource.spotify.com/cefbuilds/cef_binary_3.3325.1756.g6d8faa4_windows32.tar.bz2

64bit -> http://opensource.spotify.com/cefbuilds/cef_binary_3.3325.1756.g6d8faa4_windows64.tar.bz2

CEF4Delphi是在Delphi 10.2 Tokyo上開發和測試的,已經在Delphi 7,Delphi XE和Delphi 10中測試過了。

有關CEF4Delphi的更多信息,請訪問: https://www.briskbard.com/index.php?lang=en&pageid=cef

論壇:https://www.briskbard.com/forum

最新的組件支持 Windows 7, 8, 8.1, 10 或者更新版本.。如果需要在 Windows XP 和 Vista 中使用,請使用老版本: OldCEF4Delphi : https://github.com/salvadordf/OldCEF4Delphi

 下面的代碼是一些常用的設置, 包括將DLL文件放到一個單獨的目錄下面,以及讓 cef 使用內置的 flash:

function CefLibPath: string;
begin
{$IFDEF CPUX64}
  Result := 'CEF_3.3239.1709\Core64';
{$ELSE}
  Result := 'CEF_3.3239.1709\Core';
{$ENDIF}
end;

function PpapiFlashFileName: string;
begin
{$IFDEF CPUX64}
  Result := CefLibPath + '\plugins\pepflashplayer64.dll'
{$ELSE}
  Result := CefLibPath + '\plugins\pepflashplayer32.dll'
{$ENDIF}
end;

begin
  GlobalCEFApp := TCefApplication.Create;

  // In case you want to use custom directories for the CEF3 binaries, cache, cookies and user data.
  // If you don't set a cache directory the browser will use in-memory cache.
  GlobalCEFApp.FrameworkDirPath := CefLibPath;
  GlobalCEFApp.ResourcesDirPath := CefLibPath;
  GlobalCEFApp.LocalesDirPath   := CefLibPath + '\locales';
  GlobalCEFApp.Cache            := CefLibPath + '\cache';
  GlobalCEFApp.Cookies          := CefLibPath + '\cookies';
  GlobalCEFApp.UserDataPath     := CefLibPath + '\User Data';
  GlobalCEFApp.AcceptLanguageList:= 'zh-CN';
  GlobalCEFApp.LocalesRequired := 'zh-CN';
  GlobalCEFApp.Locale := 'zh-CN'; GlobalCEFApp.FlashEnabled :
= False; GlobalCEFApp.EnableGPU := True; // Enable hardware acceleration GlobalCEFApp.DisableGPUCache := True; // Disable the creation of a 'GPUCache' directory in the hard drive. GlobalCEFApp.AddCustomCommandLine('--ppapi-flash-path', PpapiFlashFileName); // You *MUST* call GlobalCEFApp.StartMainProcess in a if..then clause // with the Application initialization inside the begin..end. // Read this https://www.briskbard.com/index.php?lang=en&pageid=cef if GlobalCEFApp.StartMainProcess then begin Application.Initialize; {$IFDEF DELPHI11_UP} Application.MainFormOnTaskbar := True; {$ENDIF} Application.CreateForm(TForm1, Form1); Application.Run; end; GlobalCEFApp.Free; end.

 

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM