我看到theApp里面有个成员m_lpCmdLine,通过m_lpCmdLine + 1可以获取到这个路径字符串。
个人的理解这个m_lpCmdLine是操作系统传入winmain函数的入口参数,但是入口参数好像里面没有表示程序路径的参数,求大牛解惑。。

解决方案 »

  1.   

    m_lpCmdLine的第0个参数就是进程的路径。GetModuleFileName也可以得到。
      

  2.   

    发现m_pszHelpFilePath也保存着路径,我用m_pszHelpFilePath实现了。
      

  3.   

    Retrieves the fully qualified path for the file that contains the specified module. The module must have been loaded by the current process.To locate the file for a module that was loaded by another process, use the GetModuleFileNameEx function.Syntax
    C++Copy
     
    DWORD WINAPI GetModuleFileName(
      _In_opt_  HMODULE hModule,
      _Out_     LPTSTR lpFilename,
      _In_      DWORD nSize
    );
      

  4.   

    GetModuleFileName比较好,毕竟dll也能用