我最深的歉意错误调用方法。该文件未被复制到正确的目录中,因此无法读取。毕竟这个扩展工作在所有的Windows平台上。这是提醒您始终执行适当的错误处理。Chrome扩展有FireBreath插件...未捕获的错误:NPObject
直的问题:我需要上传比FireBreath生成的.dll文件更多的(需要适当的.js,.html和以.json是显而易见的)的Chrome扩展中的FireBreath插件?
大图: FireBreath生成一个.dll,我相信把装载这个.dll文件到Chrome扩展文件夹上传了使用Chrome://扩展/解压缩就足够了。换句话说,我认为我不需要上传额外的C++代码。调用plugin.openUserIdFromFile()生成我的错误。
成功:我使用NPAPI FireBreath插件将桌面用户名从文件加载到Chrome扩展。它适用于开发插件的Windows桌面。
失败:在NPObject上调用方法时出错。错误地接收所有Windows环境:XP,7或8的开发环境之外。
已知:好友跑http://www.dependencywalker.com/软件就可以了,结果发现IEShims.dll在他的环境中缺少的依赖,但我把它在上传文件夹无济于事。
JavaScript的浏览器扩展,使呼叫FireBreath插件DLL:
$(document).ready(function() {
setInterval(getAllChromeTabs, 10000);
var plugin = document.getElementById("pluginId");
while (user.length < 1) {
user = plugin.openUserIdFromFile();
}
console.log(user);
});
从Chrome扩展称为C++ FireBreath插件功能:
std::string LabStatsPluginAPI::openUserIdFromFile()
{
std::string aTempFileName = "aTempFileName";
DWORD nBufferLength = MAX_PATH;
LPTSTR lpBuffer = (new TCHAR[nBufferLength]);
DWORD tempPath = GetTempPath(nBufferLength, lpBuffer);
char* localTempPathArray = new char[nBufferLength];
for (int i = 0; i < nBufferLength; i++) {
localTempPathArray[i] = (char)lpBuffer[i];
}
std::string localTempPath(localTempPathArray);
localTempPath = localTempPath + aTempFileName;
std::ifstream streamFromFile;
std::ifstream::pos_type fileSize;
streamFromFile.open(localTempPath, std::ios::in|std::ios::binary|std::ios::ate);
char* userNameString;
int userNamesize = streamFromFile.tellg();
streamFromFile.seekg(0, std::ios::beg);
userNameString = new char[userNamesize];
streamFromFile.read(userNameString, userNamesize);
delete[] lpBuffer;
delete[] localTempPathArray;
std::string userNameSafeString(userNameString);
delete[] userNameString;
return userNameSafeString;
}