我做了个对话框界面,当执行时想得到exe文件的当前路径。请问如何实现???

解决方案 »

  1.   

    app.path:兄弟这是vb的方法
    GetCurrentDirectory:也可以
      

  2.   

    GetCurrentDirectory: is not good! If you pop an openfile dialog,and select another directory,this function will return the directory you changed.You can use GetModuleFileName, and parse its path.CString GetModulePath()
    {
    CString csModuleDir;
    char szPath[MAX_PATH];
    GetModuleFileName(::AfxGetApp()->m_hInstance,szPath,MAX_PATH);
    char szDriver[MAX_PATH];
    char szDir[MAX_PATH];
    char szFile[MAX_PATH];
    char szExt[MAX_PATH];
    _splitpath(szPath,szDriver,szDir,szFile,szExt);

    csModuleDir=szDriver;
    csModuleDir=csModuleDir+szDir;
    csModuleDir.TrimRight('\\');
    csModuleDir+='\\';
    return csModuleDir;
    }
      

  3.   

    请问Pipi0714(皮皮0714)大侠??
    GetCurrentDirectory:的用法请说详细些,好吗??谢谢!!!!
      

  4.   

    DWORD GetCurrentDirectory(
      DWORD nBufferLength,  // size, in characters, of directory buffer
      LPTSTR lpBuffer       // pointer to buffer for current directory
    );
     
    Parameters
    nBufferLength 
    Specifies the length, in characters, of the buffer for the current directory string. The buffer length must include room for a terminating null character. 
    lpBuffer 
    Pointer to the buffer for the current directory string. This null-terminated string specifies the absolute path to the current directory