bool CWebCore::Initialise () { CefMainArgs mainArgs; void* sandboxInfo = nullptr; CefRefPtr<CCefApp> app { new CCefApp }; #if CEF_ENABLE_SANDBOX CefScopedSandboxInfo scopedSandbox; sandboxInfo = scopedSandbox.sandbox_info(); #endif if ( CefExecuteProcess ( mainArgs, app, sandboxInfo ) >= 0 ) return false; CefSettings settings; #if !CEF_ENABLE_SANDBOX settings.no_sandbox = true; #endif // Specifiy sub process executable path #ifndef MTA_DEBUG CefString ( &settings.browser_subprocess_path ).FromWString( FromUTF8( CalcMTASAPath ( "MTA\\CEF\\CEFLauncher.exe" ) ) ); #else CefString ( &settings.browser_subprocess_path ).FromWString( FromUTF8( CalcMTASAPath ( "MTA\\CEF\\CEFLauncher_d.exe" ) ) ); #endif CefString ( &settings.resources_dir_path ).FromWString ( FromUTF8( CalcMTASAPath( "MTA\\CEF") ) ); CefString ( &settings.locales_dir_path ).FromWString( FromUTF8( CalcMTASAPath( "MTA\\CEF\\locales" ) ) ); CefString ( &settings.log_file ).FromWString ( FromUTF8( CalcMTASAPath ( "MTA\\CEF\\cefdebug.txt" ) ) ); #ifdef MTA_DEBUG settings.log_severity = cef_log_severity_t::LOGSEVERITY_INFO; #else settings.log_severity = cef_log_severity_t::LOGSEVERITY_WARNING; #endif settings.multi_threaded_message_loop = true; settings.windowless_rendering_enabled = true; bool state = CefInitialize ( mainArgs, settings, app, sandboxInfo ); // Register custom scheme handler factory CefRegisterSchemeHandlerFactory ( "mtalocal", "", app ); CefRegisterSchemeHandlerFactory ( "http", "mta", app ); return state; }
int _declspec(dllexport) InitCEF() { // Get absolute CEFLauncher.exe path TCHAR buffer[MAX_PATH]; GetModuleFileName(NULL, buffer, MAX_PATH); std::wstring currentFileName(buffer); // Extract MTA path and set DLL directory (absolute path is required here) size_t pos = currentFileName.find_last_of(L'\\'); std::wstring mtaPath = currentFileName.substr(0, pos - 3); // Strip "CEF" SetDllDirectory(mtaPath.c_str()); // Load CEF CefMainArgs mainArgs(GetModuleHandle(NULL)); CefRefPtr<CCefApp> app{new CCefApp}; void* sandboxInfo = nullptr; #ifdef CEF_ENABLE_SANDBOX CefScopedSandboxInfo scopedSandbox; sandboxInfo = scopedSandbox.sandbox_info(); #endif return CefExecuteProcess(mainArgs, app, sandboxInfo); }