一起学libcef--源码文件介绍(VS2015运行DEMO)
来源:互联网 发布:新加坡 经济形势 数据 编辑:程序博客网 时间:2024/06/05 05:40
昨天的博客《一起学libcef–开篇(下载、CMake的使用)》讲诉如何下载CEF,并如何得到对应vs版本的解决方案。
今天就展示一下,得到的工程文件夹中文件的作用。
include – 这个文件夹里面放CEF客户应用程序所需的头文件
libcef – 此文件夹存放CEF的静态库
libcef_dll – 此文件夹CEF的动态拉链库
tests – 此文件夹存放测试的例子
cefclient – 一个简单的客户程序
cefsimple–一个简单的例子
unittests – CEF界面单元测试
下面看一下:
下面就是运行cefsimple的界面了:
下面就是windows的入口函数:
#include <windows.h>#include "cefsimple/simple_app.h"#include "include/cef_sandbox_win.h"// When generating projects with CMake the CEF_USE_SANDBOX value will be defined// automatically if using the required compiler version. Pass -DUSE_SANDBOX=OFF// to the CMake command-line to disable use of the sandbox.// Uncomment this line to manually enable sandbox support.// #define CEF_USE_SANDBOX 1#if defined(CEF_USE_SANDBOX)// The cef_sandbox.lib static library is currently built with VS2013. It may not// link successfully with other VS versions.#pragma comment(lib, "cef_sandbox.lib")#endif// Entry point function for all processes.int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); void* sandbox_info = NULL;#if defined(CEF_USE_SANDBOX) // Manage the life span of the sandbox information object. This is necessary // for sandbox support on Windows. See cef_sandbox_win.h for complete details. CefScopedSandboxInfo scoped_sandbox; sandbox_info = scoped_sandbox.sandbox_info();#endif // Provide CEF with command-line arguments. CefMainArgs main_args(hInstance); // SimpleApp implements application-level callbacks. It will create the first // browser instance in OnContextInitialized() after CEF has initialized. CefRefPtr<SimpleApp> app(new SimpleApp); // CEF applications have multiple sub-processes (render, plugin, GPU, etc) // that share the same executable. This function checks the command-line and, // if this is a sub-process, executes the appropriate logic. int exit_code = CefExecuteProcess(main_args, app.get(), sandbox_info); if (exit_code >= 0) { // The sub-process has completed so return here. return exit_code; } // Specify CEF global settings here. CefSettings settings;#if !defined(CEF_USE_SANDBOX) settings.no_sandbox = true;#endif // Initialize CEF. CefInitialize(main_args, settings, app.get(), sandbox_info); // Run the CEF message loop. This will block until CefQuitMessageLoop() is // called. CefRunMessageLoop(); // Shut down CEF. CefShutdown(); return 0;}Linux Entry Point// cefsimple_linux.cpp#include "cefsimple/simple_app.h"#include <X11/Xlib.h>#include "include/base/cef_logging.h"namespace {int XErrorHandlerImpl(Display *display, XErrorEvent *event) { LOG(WARNING) << "X error received: " << "type " << event->type << ", " << "serial " << event->serial << ", " << "error_code " << static_cast<int>(event->error_code) << ", " << "request_code " << static_cast<int>(event->request_code) << ", " << "minor_code " << static_cast<int>(event->minor_code); return 0;}int XIOErrorHandlerImpl(Display *display) { return 0;}} // namespace// Entry point function for all processes.int main(int argc, char* argv[]) { // Provide CEF with command-line arguments. CefMainArgs main_args(argc, argv); // SimpleApp implements application-level callbacks. It will create the first // browser instance in OnContextInitialized() after CEF has initialized. CefRefPtr<SimpleApp> app(new SimpleApp); // CEF applications have multiple sub-processes (render, plugin, GPU, etc) // that share the same executable. This function checks the command-line and, // if this is a sub-process, executes the appropriate logic. int exit_code = CefExecuteProcess(main_args, app.get(), NULL); if (exit_code >= 0) { // The sub-process has completed so return here. return exit_code; } // Specify CEF global settings here. CefSettings settings; // Install xlib error handlers so that the application won't be terminated // on non-fatal errors. XSetErrorHandler(XErrorHandlerImpl); XSetIOErrorHandler(XIOErrorHandlerImpl); // Initialize CEF for the browser process. CefInitialize(main_args, settings, app.get(), NULL); // Run the CEF message loop. This will block until CefQuitMessageLoop() is // called. CefRunMessageLoop(); // Shut down CEF. CefShutdown(); return 0;}
既然源码可以运行了,我们就可以学习了。
但是源码过于庞大,我们不想太深入理解的话,就想着如何在自己的程序中使用libcef.dll这个库,这就是接下来要讨论的内容。
1 0
- 一起学libcef--源码文件介绍(VS2015运行DEMO)
- 一起学libcef--搭建自己的libcef运行环境(Win32程序,错误C2220解决方案)
- 一起学libcef--libcef的基本类和方法介绍(如何产生一个你自己的浏览器)
- 一起学libcef--开篇(下载、CMake的使用)
- 一起学libcef--给你的浏览器设置cookie
- 一起学libcef--给你的浏览器设置url
- 一起学libcef--正确关闭你创建的浏览器
- 一起学libcef--给你的浏览器删除cookie
- 一起学libcef--让你的cef执行js代码
- 一起学libcef--一个应用libcef的简单例子(windows程序)
- Libcef源码下载与编译
- 一起学Netty(十二)之 Netty心跳简单Demo
- 一起学Netty(十二)之 Netty心跳简单Demo
- 一起学Netty(十二)之 Netty心跳简单Demo
- 与afreez一起学习DirectFB之:如何高效的运行DirectFB程序,即Directfbrc文件介绍
- 一起学Git:Git文件状态
- 一起学docker(3)--安装并运行ubuntu
- 和菜鸟一起学OK6410之熟悉内核源码
- Concurrent包
- 线程使用经验
- 性能-客户端测试(二)
- 用户行为分析业务系统日志处理方案
- Python调用C/C++初步
- 一起学libcef--源码文件介绍(VS2015运行DEMO)
- 数据结构与算法(线性表_顺序表存储结构)
- project euler 22
- JAVA 栈数据结构及其应用
- asio1
- js回到顶部,关闭一个模块的方法
- IOS OC 字典
- PAT甲级1005
- poj1028 Web Navigation