【问题标题】:How to get application path in Windos Mobile using Visual C++如何使用 Visual C++ 在 Windows Mobile 中获取应用程序路径
【发布时间】:2010-11-19 20:54:28
【问题描述】:

我有一个应用程序,它从相对于应用程序所在位置的“images\”文件夹加载少量图像文件。任何人都可以让我知道如何在 Visual C++ 中获取位置。快速谷歌搜索显示,没有直接的方法。谁能帮我解决这个问题?

谢谢 私信

【问题讨论】:

    标签: visual-c++ windows-mobile


    【解决方案1】:

    使用 GetModuleFilename() 获取应用程序的完整路径并去掉可执行文件名:

        wchar_t appPath[ MAX_PATH ];
        memset( appPath, 0, MAX_PATH * sizeof( wchar_t ) );
    
        wchar_t modulePath[MAX_PATH];
        if ( GetModuleFileName( NULL, modulePath, MAX_PATH ) > 0 )
        {
            wchar_t *lastBackSlash = wcsrchr( modulePath, '\\' );
            if ( lastBackSlash )
            {
                memcpy( appPath, modulePath, ( lastBackSlash - modulePath ) * sizeof( wchar_t ) );
            }
        }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-11-22
      • 1970-01-01
      • 2011-09-08
      • 1970-01-01
      • 1970-01-01
      • 2011-05-16
      • 1970-01-01
      相关资源
      最近更新 更多