2018-06-18 17:01:44 +02:00
|
|
|
unit uCEFLoader;
|
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
implementation
|
|
|
|
|
|
|
|
uses
|
|
|
|
uCEFApplication;
|
|
|
|
|
|
|
|
procedure CreateGlobalCEFApp;
|
|
|
|
begin
|
2021-03-20 13:16:08 +01:00
|
|
|
// In case you prefer to call CreateGlobalCEFApp and DestroyGlobalCEFApp manually
|
|
|
|
// you have to remember that GlobalCEFApp can only be initialized *ONCE* per process.
|
|
|
|
// This is a CEF requirement and there's no workaround.
|
|
|
|
if (GlobalCEFApp <> nil) then
|
|
|
|
exit;
|
|
|
|
|
2018-06-18 17:01:44 +02:00
|
|
|
GlobalCEFApp := TCefApplication.Create;
|
2021-03-20 13:16:08 +01:00
|
|
|
GlobalCEFApp.BrowserSubprocessPath := 'SimpleBrowser_sp.exe';
|
2018-06-18 17:01:44 +02:00
|
|
|
|
2019-10-19 10:58:34 +02:00
|
|
|
// In case you want to use custom directories for the CEF binaries, cache and user data.
|
2018-06-18 17:01:44 +02:00
|
|
|
// If you don't set a cache directory the browser will use in-memory cache.
|
2019-09-19 14:14:03 +02:00
|
|
|
// The cache and user data directories must be writable.
|
2018-06-18 17:01:44 +02:00
|
|
|
{
|
|
|
|
GlobalCEFApp.FrameworkDirPath := 'cef';
|
|
|
|
GlobalCEFApp.ResourcesDirPath := 'cef';
|
|
|
|
GlobalCEFApp.LocalesDirPath := 'cef\locales';
|
|
|
|
GlobalCEFApp.cache := 'cef\cache';
|
|
|
|
GlobalCEFApp.UserDataPath := 'cef\User Data';
|
|
|
|
}
|
|
|
|
|
|
|
|
// This demo uses a different EXE for the subprocesses.
|
|
|
|
// With this configuration it's not necessary to have the
|
|
|
|
// GlobalCEFApp.StartMainProcess call in a if..then clause.
|
|
|
|
GlobalCEFApp.StartMainProcess;
|
|
|
|
end;
|
|
|
|
|
|
|
|
initialization
|
|
|
|
CreateGlobalCEFApp;
|
|
|
|
|
|
|
|
finalization
|
|
|
|
DestroyGlobalCEFApp;
|
|
|
|
|
|
|
|
end.
|