VS2013编译最简单的PPAPI插件

                       

我想在CEF里使用PPAPI,CEF使用VS 2013 Update 4编译。因此我尝试了使用VS 2013来编译PPAPI插件。

PPAPI的代码在这里:https://chromium.googlesource.com/chromium/src/ppapi/,可以用下列命令check出来:

git clone https://chromium.googlesource.com/chromium/src/ppapi
  
  
  • 1

也可以下载master分支的tgz包。

VS工程

新建一个Win32项目,类型选DLL,去掉预编译头文件stdafx.h和stdafx.cpp,并且在项目属性–>配置属性–>C/C++–>预编译头,把预编译头选项的值设置为不使用预编译头。

复制ppapi/examples/stub/stub.c文件到项目文件夹下,并添加到项目里。做简单修改,打印点儿调试信息。stub.c内容如下:

// Copyright (c) 2010 The Chromium Authors. All rights reserved.// Use of this source code is governed by a BSD-style license that can be// found in the LICENSE file.// This is the simplest possible C Pepper plugin that does nothing. If you're// using C++, you will want to look at stub.cc which uses the more convenient// C++ wrappers.#include <stddef.h>#include <stdint.h>#include <Windows.h>#include <tchar.h>#include "ppapi/c/pp_errors.h"#include "ppapi/c/pp_module.h"#include "ppapi/c/ppb.h"#include "ppapi/c/ppp.h"#include "ppapi/c/pp_instance.h"#include "ppapi/c/ppp_instance.h"PP_Module g_module_id;PPB_GetInterface g_get_browser_interface = NULL;PP_EXPORT int32_t PPP_InitializeModule(PP_Module module_id,   PPB_GetInterface get_browser_interface) {  // Save the global module information for later.  g_module_id = module_id;  g_get_browser_interface = get_browser_interface;  OutputDebugString(_T("PPP_InitializeModule was called\r\n"));  return PP_OK;}PP_EXPORT void PPP_ShutdownModule() {OutputDebugString(_T("PPP_ShutdownModule was called\r\n"));}PP_EXPORT const void* PPP_GetInterface(const char* interface_name) {  // You will normally implement a getter for at least PPP_INSTANCE_INTERFACE  // here.  OutputDebugString(_T("PPP_GetInterface was called\r\n"));  return NULL;}
  
  
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43

PPAPI plugin

参考https://code.google.com/p/ppapi/wiki/GettingStarted,C语言版的PPAPI plugin,必须实现下列函数:

  • PPP_InitializeModule,插件加载时会被调用,返回0表示成功
  • PPP_ShutdownModule,插件卸载时会被调用
  • PPP_GetInterface,浏览器创建插件实例时会被调用

这些函数在ppp.h中定义。实现这些函数时,使用PP_EXPORT宏修饰一下即可。

一个DLL,实现了上述三个函数,就可以做为PPAPI插件来用了,不过只是样子货,只能看到被加载、创建,干不了什么实际的事儿,是个PPAPI 版本的Hello World。

后面我们会改造stub,显示点东西出来。


相关文章参考:

           

再分享一下我老师大神的人工智能教程吧。零基础!通俗易懂!风趣幽默!还带黄段子!希望你也加入到我们人工智能的队伍中来!https://blog.csdn.net/jiangjunshow

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值