Tuesday, April 7, 2009

wxStandardPaths().GetDataDir()

wxStandardPaths().GetDataDir()
这个函数可以用来非常方便的取得exe的位置。(Manual)
可是用vc编译的debug版却没有包含最后的debug目录。
很是疑惑啊!
以为vc添加了什么神奇的东西。
看了
wxStandardPaths::GetDataDir() 的源代码,

wxString wxStandardPaths::GetDataDir() const
{
    // under Windows each program is usually installed in its own directory and
    // so its datafiles are in the same directory as its main executable
    return GetAppDir();
}

wxString wxStandardPaths::GetAppDir()
{
    wxFileName fn(wxGetFullModuleName());

    // allow running the apps directly from build directory in debug builds
#ifdef __WXDEBUG__
    wxString lastdir;
    if ( fn.GetDirCount() )
    {
        lastdir = fn.GetDirs().Last();
        lastdir.MakeLower();
        if ( lastdir.Matches(_T("debug*")) || lastdir.Matches(_T("vc_msw*")) )
            fn.RemoveLastDir();
    }

No comments:

Post a Comment