2

如何获得模块的路径?

我正在编写包含在 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());
4

3 回答 3

4

看看wxStandardPaths课堂。对于您的问题,可以使用它GetExecutablePath()GetPluginsDir()方法 - 我只是不确定您想做什么。

于 2009-06-13T18:28:38.703 回答
3

我用了

    #include "wx/stdpaths.h"
    #include "dialogsApp.h"
    #include "dialogsMain.h"

    IMPLEMENT_APP(dialogsApp);

    bool dialogsApp::OnInit()
    {

        wxString xpath;
        xpath = wxStandardPaths::Get().GetExecutablePath();

这似乎行得通。

于 2012-11-12T05:48:05.247 回答
0

这不是 wxWidgets 特定的。Windows 有一个名为GetModuleFileName的函数,它可以满足您的需求。该链接指向 msdn 页面。

于 2009-06-13T17:59:19.773 回答