Firefox插件基于Mozilla开源的NSAPI.
mioPlugIn采用目前(2009.08)最新的、适合脚本驱动的npruntime架构.
https://developer.mozilla.org/en/Gecko_SDK
目前(2009.08)使用以下版本
http://releases.mozilla.org/pub/mozilla.org/xulrunner/releases/1.9.1.2/sdk/xulrunner-1.9.1.2.en-US.win32.sdk.zip
http://mxr.mozilla.org/seamonkey/source/modules/plugin/samples/npruntime/
1.建立新工程
File->New Project->Vistual C++
Project types选择Visual C++/Win32 Project
Templates选择Win32 Project
Solution Name名称假定为nprt,必须以np开头.
2.Application Settings
3. 加入npruntime架构示例代码到工程中
(a) copy所有从 http://mxr.mozilla.org/seamonkey/source/modules/plugin/samples/
下载的文件到nprt/nprt目录中
(b) 加入nprt工程中
4.解压Mozilla SDK,假定放在C:/xulrunner-sdk(必须与“2.5设置Include Path”一致)
5.设置Include Path
"C:/xulrunner-sdk/include";"C:/xulrunner-sdk/include/plugin"; "C:/xulrunner-sdk/include/nspr";"C:/xulrunner-sdk/include/java"
6.设置编译选项
WIN32;_WINDOWS;XP_WIN32;MOZILLA_STRICT_API;XPCOM_GLUE;XP_WIN;_X86_; NPSIMPLE_EXPORTS; _DEBUG
7.关闭precompiled选项
8.设定 Module Definition File: nprt.def
9.修改plugin.cpp DrawText为DrawTextA
10.修改plugin.cpp Invoke method如下,否则当firefox调用此plugin时,会崩溃
------------------------------------------------------------------
bool ScriptablePluginObject::Invoke(NPIdentifier name, const NPVariant *args, uint32_t argCount, NPVariant *result) { if (name == sFoo_id) { printf ("foo called!/n"); MessageBox(NULL,L"foo 被调用 ",L"Java Script 调用范例",MB_OK); return PR_TRUE; } return PR_FALSE; }
------------------------------------------------------------------
11.修改npp_gate.cpp , 去掉_GetJavaClass
------------------------------------------------------------------
/* jref NPP_GetJavaClass (void) { return NULL; } */
------------------------------------------------------------------
12修改几处
#include "npupp.h"
为
//#include "npupp.h" #include "plugin/npfunctions.h"
不然编译报错
12.注解所有 printf
13.适当修改 int32 uint32 等为 int32_t uint32_t等
14.编译即可生成nprt.dll
[图片上传功能暂时关闭,敬请谅解。]...