2011-12-14 17 views
2

Backgoundは、手順基本的なプラグイン(NPAPI /のNPRuntime)こんにちは、世界

    ここから
  1. に使用Mozillaコード:ファイルの上に追加のVisual Studio &でhttp://mxr.mozilla.org/seamonkey/source/modules/plugin/tools/sdk/samples/basic/windows/
  2. 新しい空のプロジェクト
  3. 変更Congfigurationタイプ:ダイナミック・ライブラリー( .dll) 3b。リンカー>入力 - >モジュール定義ファイル:BasicPlugin.def
  4. に、BasicPlugin.cppコメントは基本機能のみを持っているとFirefoxのプラグインディレクトリにコピーされたHello Worldの
  5. コンパイル(成功し)&ため
  6. はチェック済みメッセージボックスをDISPLY :(失敗した)DLLを呼び出すためのプラグイン(い)
  7. 負荷HTML

私は今のNPRuntimeファイルを使用してscriptibleプラグイン(かどうかはわかりません)を作成しようとしています。しかし、なぜプラグインが読み込まれないのかわかりません。これはすべての基本的な基本です。誰にでもこれに関するアイデアはありますか?

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> 

答えて

3

あなたはそれが動作しませんWindows上でこれを実行しようとしている場合は、ウィンドウのエントリポイントが間違っています。あなたがリストしたものは、linuxのエントリーポイントです。 FireBreathのWindowsエントリポイントファイルについてはhttps://github.com/firebreath/FireBreath/blob/master/src/PluginAuto/Win/np_winmain.cppを参照してください。また、仮に他のものの多くがあるかもしれません

編集http://npapi.com/tutorial

で説明しました。プロジェクト全体を見ることなく、推測するのは難しいです。 about:プラグインに表示されているので、文字列リソースが適切に配置されています。 .defファイルでシンボルを正しくエクスポートしていますか? DllMainは呼び出されますか? (そこにメッセージボックスを使用せず、何かをログに記録するか、ブレークポイントを設定しないでください)

また、FireBreathは完全に機能するnpapiプラグインを作成する例です(NPAPIプラグインを作成する方がはるかに簡単です)。あなたはそれを見ることから多くを学ぶかもしれません。その作品のどれも私があなたのプロジェクト全体を見ることなく推測することはできませんでした。おそらくギタープロジェクトや何か?

+0

そうにNP_GetEntryPointsのエントリポイントを変更: NPError OSCALL NP_GetEntryPoints(NPPl​​uginFuncs * pFuncs) とNP_Initialize: NPError FAR PASCAL NP_Initialize(NPNetscapeFuncs * pFuncsは)それを解決していないことは、エントリ・ポイント以外の何か他のものがあります? – hapyfishrmn

+0

私はブレークポイントを設定することができません、VSは、シンボルがロードされていないと言います。 – hapyfishrmn

+0

解決策は、VSで私はリンカーにdefファイルを追加していないということでした。助けてくれてありがとう! – hapyfishrmn

関連する問題