wxWidgets:获取应用程序路径
问题描述:
如何获取模块路径?wxWidgets:获取应用程序路径
我正在写扩展名,并附在一个DLL中,并希望在运行时获得我的库的路径。
更新
当然第一种方式工作得很好
static wxString GetModulePath()
{
static wxString path;
WCHAR buf[512] = {0};
GetModuleFileName(NULL, buf, 511);
path = buf;
return wxPathOnly(path);
}
但最后我用第二个
wxStandardPaths sp;
wxLogError(sp.GetPluginsDir());
答
我用
#include "wx/stdpaths.h"
#include "dialogsApp.h"
#include "dialogsMain.h"
IMPLEMENT_APP(dialogsApp);
bool dialogsApp::OnInit()
{
wxString xpath;
xpath = wxStandardPaths::Get().GetExecutablePath();
,似乎工作。
我只是在寻找'正确','跨平台'的方式 – jonny 2009-06-13 18:03:20
既然你已经接受了第一个答案,我对你真正想要实现的东西有点困惑:从宿主应用程序中获取扩展的位置?一旦它被加载,从它自己获取扩展模块的位置?如果跨平台,为什么接受与Windows API函数的答案? – mghie 2009-06-13 18:32:28
从它自己获取扩展模块的位置,一旦它被加载。 – jonny 2009-06-13 18:47:19