0

我已经使用 firebreath 开发了 npapi 插件。我想访问放置在计算机内的一张图像。我很困惑如何在插件类中给出文件路径,还是需要将它放在其他指定的文件夹中?请帮忙。

4

1 回答 1

2

在您的主要插件对象中,您可以调用getFSPath () 来获取插件 .dll 的完整路径和文件名。您可以使用它来查找要打开的资源文件的相对路径。

在 1.7 或更高版本(1.7 于 2012 年 12 月 17 日发布)中,您可以在任何地方#include "BrowserPlugin.h"使用BrowserPlugin::getFSPath()。从那里开始,它只是一个简单的字符串操作,或者如果你想更完整/更简单,你可以使用 boost::filesystem

#include <BrowserPlugin.h>
#include <boost/filesystem.hpp>
using namespace boost::filesystem;

// ....

std::string getPluginDirPath() {
    path pluginPath(BrowserPlugin::getFSPath());
    return pluginPath.parent_path().string();
}
于 2012-12-19T17:03:01.927 回答