0

雖然在嘗試編譯下面的Chrome插件之前,我只做了很少的C++,所以我可以看到它是如何工作的,並以此爲出發點開發類似的東西:http://code.google.com/p/minimizetotray/source/browse/trunk/?r=17#trunk%2FDLL新手Chrome插件開發人員需要幫助開始使用NPAPI

到目前爲止,我採取了以下步驟:下載源代碼,在MS Visual Studio Pro 2008中打開它,並獲得一些SDK和包含最新版本的NPAPI的頭文件標題:http://npapi-sdk.googlecode.com/svn/trunk/headers/

現在,當我嘗試編譯並且不知道如何對此進行排序時,出現以下錯誤。

Compiling... 
JSMethods.cpp 
c:\documents and settings\dell customer\desktop\dll\jsmethods.cpp(92) : error C2039: 'UTF8length' : is not a member of '_NPString' 
     c:\program files\microsoft visual studio 9.0\vc\include\plugin\npruntime.h(85) : see declaration of '_NPString' 
c:\documents and settings\dell customer\desktop\dll\jsmethods.cpp(101) : error C2039: 'UTF8characters' : is not a member of '_NPString' 
     c:\program files\microsoft visual studio 9.0\vc\include\plugin\npruntime.h(85) : see declaration of '_NPString' 

等...

除了這兩個錯誤,這一切似乎花花公子,它不要求丟失包括或任何東西。任何幫助感謝!

+0

您使用的是哪個版本的XulRunner SDK? –

+0

你可能也想看看http://firebreath.org而不是手工做 - 這很容易,尤其是對於一個新手來說(但許多高級插件開發者也使用它) – taxilian

回答

0

除非我記錯的_NPString結構被定義爲最新的SDK ...

typedef char NPUTF8; 
typedef struct _NPString { 
    const NPUTF8 *UTF8Characters; 
    uint32_t UTF8Length; 
} NPString; 

而且在你的代碼中呼籲UTF8length而不是UTF8Length(大寫L)。

+0

它編譯,wahooooooooo!猜猜如果我真的嘗試過了,我可以自己完成一項工作,我發佈的匿名工作很好:-P不知道爲什麼我製作的DLL是分發版本的三倍大小,但似乎工作正常,謝謝加載你的幫助! –

+0

也許你在設置「在靜態庫中使用MFC」......一個開始使用NPAPI的好地方是http://colonelpanic.net/2009/03/building-a-firefox-plugin-part-one/ –

+0

這意味着代碼也需要更改爲使用UTF8Characters而不是UTF8字符: std :: string ret = NPVARIANT_TO_STRING(locationValue).UTF8Characters; –