Example #1
0
int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine, int nCmdShow)
{
	CefEnableHighDPISupport();

	CefMainArgs mainArgs(hInst);

	CefRefPtr<CefCommandLine> cmdLine = CefCommandLine::CreateCommandLine();
	cmdLine->InitFromString(::GetCommandLineW());

	CefRefPtr<CefApp> app;
	auto appType = GetAppType(cmdLine);
	if (appType == AppType::BROWSER)
		app = new BrowserApp();
	else if (appType == AppType::RENDERER)
		app = new RendererApp();

	int exitCode = CefExecuteProcess(mainArgs, app, nullptr);
	if (exitCode >= 0)
		return exitCode;

	CefSettings settings;
	settings.no_sandbox = true;
	settings.remote_debugging_port = 1337;
	CefString(&settings.cache_path).FromASCII("./cache/");

	CefInitialize(mainArgs, settings, app, nullptr);

	CefRunMessageLoop();

	CefShutdown();

	return 0;
}
Example #2
0
int main(int argc, char* argv[])
{
	CefEnableHighDPISupport();

	CefMainArgs mainArgs(argc, argv);

	auto cmdLine = CefCommandLine::CreateCommandLine();
	cmdLine->InitFromArgv(argc, argv);

	std::string configPath = cmdLine->GetSwitchValue("config").ToString();
	if (configPath.empty())
	{
		configPath = "config.default.json";
	}

	AppConfig config;
	if (!LoadAppConfig(configPath.c_str(), &config))
	{
		return -1;
	}

	CefRefPtr<CefApp> app(new App(config));

	int exitCode = CefExecuteProcess(mainArgs, app, nullptr);
	if (exitCode >= 0)
	{
		return exitCode;
	}

	CefSettings settings;
	settings.no_sandbox = true;
	settings.remote_debugging_port = 1337;
	settings.single_process = false;
	CefString(&settings.cache_path).FromASCII(CACHE_PATH);

	CefInitialize(mainArgs, settings, app, nullptr);

	CefRunMessageLoop();

	CefShutdown();

	return 0;
}
Example #3
0
int QCefInit(int& argc, char** argv)
{
	HINSTANCE hInstance = static_cast<HINSTANCE>(GetModuleHandle(nullptr));

	CefMainArgs mainArgs(hInstance);
	CefRefPtr<QCefClientApp> app(new QCefClientApp);

	int exit_code = CefExecuteProcess(mainArgs, app.get(), nullptr);
	if (exit_code >= 0) {
		return exit_code;
	}

	CefSettings settings;
	QCefInitSettings(settings);

	CefInitialize(mainArgs, settings, app, nullptr);

	g_handler = new QCefClientHandler();

	return -1;
}
Example #4
0
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);
}