當(dāng)前位置:首頁 > IT技術(shù) > Windows編程 > 正文

NPAPI最簡單的代碼
2021-08-07 13:56:19

具體代碼編譯參考下載的鏈接:

https://download.csdn.net/download/quantum7/11988429

?

注意,需要的接口版本必須是1.9.0.17:

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "npupp.h"

NPNetscapeFuncs NPNFuncs;


char *
NP_GetMIMEDescription()
{
  return (char*)"application/mozill-plugin6:.foo5:Scriptability Plugin5";
}

NPError
NP_GetValue(void* future, NPPVariable variable, void *value)
{
  //return NPP_GetValue((NPP_t *)future, variable, value);

  NPP instance = (NPP_t *)future;

  if(instance == NULL)
    return NPERR_INVALID_INSTANCE_ERROR;

  switch (variable) {
  case NPPVpluginNameString:
    *((char **)value) = (char*)"NPRuntimeTest";
    break;

  case NPPVpluginDescriptionString:
    *((char **)value) = (char*)"NPRuntime scriptability API test plugin";
    break;

  case NPPVpluginScriptableNPObject:
    //*(NPObject **)value = plugin->GetScriptableObject();
    break;

  default:
    return NPERR_GENERIC_ERROR;
  }

  return NPERR_NO_ERROR;
}

編譯辦法:

XULRUNNER=xulrunner-sdk-190

rm *.so
rm *.o

g++ -shared -fPIC 
    np_entry.cpp 
    -I ${XULRUNNER}/include 
    -I ${XULRUNNER}/include/nspr 
    -I ${XULRUNNER}/include/plugin 
    -I ${XULRUNNER}/include/java 
    -I/usr/include/gtk-2.0 
    -I/usr/include/glib-2.0 
    -I/usr/include/pango-1.0 
    -I/usr/lib64/glib-2.0/include 
    -I/usr/include/cairo 
    -I/usr/include/gdk-pixbuf-2.0 
    -I/usr/include/atk-1.0 
    -o libnprt.so 
   `pkg-config --libs --cflags gtk+-2.0`

?

本文摘自 :https://blog.51cto.com/u

開通會員,享受整站包年服務(wù)立即開通 >