Backgound步骤
我正在尝试使用npruntime文件并制作一个可编写脚本的插件(不确定如何)。但我不明白为什么插件没有加载。这似乎是所有基本的基础。有没有人有这方面的想法?
BasicPlugin.cpp
#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 的
<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>
答案 0 :(得分:3)
如果你试图在Windows上运行它,那么它将无法工作;你有错误的Windows入口点。你列出的是linux的入口点。有关FireBreath的Windows入口点文件,请参阅https://github.com/firebreath/FireBreath/blob/master/src/PluginAuto/Win/np_winmain.cpp;也在http://npapi.com/tutorial
中解释过修改强>
假设可能还有很多其他的东西;没有看到你的整个项目,很难推测。它出现在about:plugins中,所以你的字符串资源就位了。您是否正确使用.def文件导出符号? DllMain会被叫到吗? (不要在那里使用消息框,只记录一些东西或设置断点)
同样,FireBreath(除了是一种更容易创建NPAPI插件的方式之外)创建一个功能齐全的npapi插件的示例;你可以从中看到很多东西。如果没有这些工作,我无法在没有看到整个项目的情况下开始推测;也许作为github项目或什么?