2011-12-14 3 views
2

backgound에이 단계를기본 플러그인 (NPAPI/npruntime) 안녕하세요 세계

    여기에서
  1. 사용 모질라 코드 : 파일 위에 추가 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 댓글은 기본적인 기능을 가지고와 파이어 폭스 플러그인 디렉토리에 복사 안녕하세요
  5. 컴파일 (성공적인) &에 대한
  6. 이 검사 MessageBox에를 disply 약 : 나는 (방법을 잘) 지금 npruntime 파일을 사용하고 scriptible 플러그인을 만들려고 노력하고

(발견) 플러그인

  • 로드 HTML은 DLL을 호출 (실패)합니다. 하지만 플러그인이 왜로드되지 않는지 이해가 안됩니다. 이것은 모든 기본적인 기본입니다. 어떤 이에 게 아이디어가 있습니까?

    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

    당신이 다음이 작동하지 않습니다 창에서이 작업을 실행하려는 경우; 당신은 창에 대한 잘못된 엔트리 포인트가 있습니다. 나열된 항목은 Linux의 엔트리 포인트입니다. FireBreath의 windows entrypoints 파일은 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 프로젝트 또는 무언가로? NPError OSCALL NP_GetEntryPoints (NPPluginFuncs * pFuncs) 및 NP_Initialize :

    +0

    그래서에 NP_GetEntryPoints의 진입 점을 변경 NPError FAR PASCAL NP_Initialize (NPNetscapeFuncs은 * pFuncs이) 그것을 해결하지 않았다 진입 점 외에 다른 뭔가가있다 ? – hapyfishrmn

    +0

    Im은 중단 점을 설정할 수 없으며 VS는로드 된 기호가 없음을 나타냅니다. – hapyfishrmn

    +0

    글쎄, 솔루션은 VS에서 링커에 def 파일을 추가하지 않는다는 것입니다. 도와 주셔서 감사합니다! – hapyfishrmn