public static bool Load(PlatformArch arch = PlatformArch.Auto, string libCefPath = null, string resourcesPath = null, string localesPath = null, string cachePath = null) { var subprocessPath = Application.StartupPath; if (string.IsNullOrEmpty(libCefPath)) { libCefPath = Application.StartupPath; } if (string.IsNullOrEmpty(resourcesPath)) { resourcesPath = libCefPath; } if (string.IsNullOrEmpty(localesPath)) { localesPath = System.IO.Path.Combine(libCefPath, "locales"); } if (arch == PlatformArch.Auto) { if (PlatformArchitecture == PlatformArch.x86) { libCefPath = System.IO.Path.Combine(libCefPath, "x86"); } else { libCefPath = System.IO.Path.Combine(libCefPath, "x64"); } } CfxRuntime.LibCefDirPath = libCefPath; if (string.IsNullOrEmpty(cachePath)) { cachePath = System.IO.Path.Combine(appDataDir, "Cache"); } appCacheDir = cachePath; var libCfxName = "libcfx.dll"; if (PlatformArchitecture == PlatformArch.x64) { libCfxName = "libcfx64.dll"; } var cfxLibPath = System.IO.Path.Combine(libCefPath, libCfxName); BrowserCore.OnBeforeCfxInitialize += (args) => { if (!System.IO.Directory.Exists(cachePath)) { System.IO.Directory.CreateDirectory(cachePath); } args.Settings.CachePath = cachePath; args.Settings.LocalesDirPath = localesPath; args.Settings.ResourcesDirPath = resourcesPath; args.Settings.LogSeverity = CfxLogSeverity.Disable; args.Settings.LogFile = System.IO.Path.Combine(args.Settings.CachePath, "debug.log"); args.Settings.Locale = "zh-CN;en-US"; BeforeCefInitialize?.Invoke(args); }; BrowserCore.OnBeforeCommandLineProcessing += (args) => { BeforeCefCommandLineProcessing?.Invoke(args); }; try { Application.ApplicationExit += OnApplicationExit; BrowserCore.Initialize(); BrowserCore.RemoteProcessCreated += OnRemoteProcessCreated; isCefInitialized = true; return(true); } catch (Exception ex) { Console.WriteLine(ex.InnerException == null ? ex : ex.InnerException); } return(false); }