我正在尝试让 Firefox(Windows 7 x64 Professional 下的 16.0.2)检测空白 NPAPI 插件。这是我的代码。
nplithium.def
LIBRARY nplithium
EXPORTS
NP_GetEntryPoints @1
NP_Initialize @2
NP_Shutdown @3
nplithium.rc
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (United States) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "CompanyName", "Antek SRL"
VALUE "FileDescription", "Example Lithium"
VALUE "FileVersion", "1.0.0.2"
VALUE "InternalName", "nplithium"
VALUE "LegalCopyright", "Copyright (C) Marco Buzzanca 2012"
VALUE "MIMEType", "application/x-lithium"
VALUE "OriginalFilename", "nplithium.dll"
VALUE "ProductName", "lithium"
VALUE "ProductVersion", "1.0.0.1"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
#endif // English (United States) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
dll_entry.cpp
#include "npapi.h"
#include "npfunctions.h"
extern "C"
{
NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* functions)
{
if(functions == NULL)
return NPERR_INVALID_FUNCTABLE_ERROR;
if(functions->size < sizeof(NPPluginFuncs))
return NPERR_INVALID_FUNCTABLE_ERROR;
functions->version = (NP_VERSION_MAJOR << 8) | NP_VERSION_MINOR;
functions->newp = NULL;
functions->destroy = NULL;
functions->setwindow = NULL;
functions->newstream = NULL;
functions->destroystream = NULL;
functions->asfile = NULL;
functions->writeready = NULL;
functions->write = NULL;
functions->print = NULL;
functions->event = NULL;
functions->urlnotify = NULL;
functions->getvalue = NULL;
functions->setvalue = NULL;
functions->javaClass = NULL;
return NPERR_NO_ERROR;
}
NPError OSCALL NP_Initialize(NPNetscapeFuncs* functions)
{
return NPERR_NO_ERROR;
}
NPError OSCALL NP_Shutdown()
{
return NPERR_NO_ERROR;
}
}
不幸的是,我在网上找到的所有示例插件和教程要么已过时,要么不完整。MDN 也无济于事,因为它几乎没有提供关于浏览器期望这些函数做什么的信息(NP_GetEntryPoints 完全没有文档记录)。
有什么我想念的吗?我不是想让插件做任何事情,我只是想让 firefox 检测到它。