Plugins 基本插件(NPAPI/npruntime)Hello world
后台阶Plugins 基本插件(NPAPI/npruntime)Hello world,plugins,npapi,npruntime,Plugins,Npapi,Npruntime,后台阶 在此处使用了Mozilla代码: 在Visual Studio中新建空项目并添加了上述文件 更改的配置类型:动态库(.dll) 3b。链接器->输入->模块定义文件:basiclugin.def 注释BasicPlugin.cpp,仅具有基本功能,并显示Hello World的MessageBox 编译(成功)&复制到Firefox插件目录 检查:插件(已找到) 加载HTML以调用dll(失败) 我现在正在尝试使用npruntime文件,并制作一个可编写脚本的插件(不知道如何编写)。但是
Mozilla测试用例的基本插件示例
此测试用例用于演示基本插件示例。你应该会收到一个留言框,上面写着“你好,世界”。
如果您试图在windows上运行此功能,那么它将无法工作;windows的入口点不正确。您列出的是linux的入口点。有关FireBreath的windows入口点文件,请参见;也在
编辑
假设还有很多其他的事情;没有看到你的整个项目,很难推测。它出现在大约:插件中,所以字符串资源已经就位。是否使用.def文件正确导出符号?德尔曼有人打电话吗?(不要在那里使用messagebox,只需记录一些内容或设置断点)
同样,FireBreath(除了是一种更容易创建NPAPI插件的方法外)是创建功能完整的NPAPI插件的一个例子;你可以从中学到很多东西。如果这些都不起作用,我就不能在没有看到你整个项目的情况下开始推测;可能是github项目或其他什么?因此将NP_GetEntryPoints的入口点更改为:NPError OSCALL NP_GetEntryPoints(NPPluginFuncs*pFuncs)和NP_Initialize:NPError FAR PASCAL NP_Initialize(NPNetscapeFuncs*pFuncs)没有解决它除了入口点还有什么吗?我无法设置断点,VS说没有加载任何符号。解决方案是在VS中,我没有将def文件添加到链接器。谢谢你的帮助!
#include "BasicPlugin.h"
NPError NP_Initialize(NPNetscapeFuncs* bFuncs, NPPluginFuncs* pFuncs)
{
MessageBox(NULL,"Hello World","NP_Initialize",MB_OK);
// Check the size of the provided structure based on the offset of the last member we need.
pFuncs->newp = NPP_New;
pFuncs->destroy = NPP_Destroy;
pFuncs->setwindow = NPP_SetWindow;
pFuncs->newstream = NPP_NewStream;
pFuncs->destroystream = NPP_DestroyStream;
pFuncs->asfile = NPP_StreamAsFile;
pFuncs->writeready = NPP_WriteReady;
pFuncs->write = NPP_Write;
pFuncs->print = NPP_Print;
pFuncs->event = NPP_HandleEvent;
pFuncs->urlnotify = NPP_URLNotify;
pFuncs->getvalue = NPP_GetValue;
pFuncs->setvalue = NPP_SetValue;
return NPERR_NO_ERROR;
}
//NP_EXPORT(char*) NP_GetPluginVersion()
//{return PLUGIN_VERSION;}
//NP_EXPORT(const char*) NP_GetMIMEDescription()
//{return "application/basic-plugin:bsc:Basic plugin";}
NPError NP_GetValue(void* future, NPPVariable aVariable, void* aValue)
{return NPERR_NO_ERROR;}
NPError OSCALL NP_Shutdown()
{return NPERR_NO_ERROR;}
NPError NPP_New(NPMIMEType pluginType, NPP instance, uint16_t mode, int16_t argc, char* argn[], char* argv[], NPSavedData* saved)
{
MessageBox(NULL,"Hello World","NPP_New",MB_OK);
return NPERR_NO_ERROR;
}
NPError NPP_Destroy(NPP instance, NPSavedData** save)
{return NPERR_NO_ERROR;}
NPError NPP_SetWindow(NPP instance, NPWindow* window)
{
MessageBox(NULL,"Hello World","NPP_SetWindow",MB_OK);
return NPERR_NO_ERROR;
}
NPError NPP_NewStream(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16_t* stype)
{return NPERR_GENERIC_ERROR;}
NPError NPP_DestroyStream(NPP instance, NPStream* stream, NPReason reason)
{return NPERR_GENERIC_ERROR;}
int32_t NPP_WriteReady(NPP instance, NPStream* stream)
{return 0;}
int32_t NPP_Write(NPP instance, NPStream* stream, int32_t offset, int32_t len, void* buffer)
{return 0;}
void NPP_StreamAsFile(NPP instance, NPStream* stream, const char* fname) {}
void NPP_Print(NPP instance, NPPrint* platformPrint) {}
int16_t NPP_HandleEvent(NPP instance, void* event)
{return 1;}
void NPP_URLNotify(NPP instance, const char* URL, NPReason reason, void* notifyData) {}
NPError NPP_GetValue(NPP instance, NPPVariable variable, void *value)
{return NPERR_GENERIC_ERROR;}
NPError NPP_SetValue(NPP instance, NPNVariable variable, void *value)
{return NPERR_GENERIC_ERROR;}
<html>
<body>
<center><h1>Basic Plugin Example for Mozilla Test Case</h1></center>
This test case is to demonstrate the Basic Plugin example. You should get a message box saying Hello World.
<br><br>
<center><embed type="application/basic-plugin" border=1 width=600 height=40></center>
</body>
</html>