char szFileName[512];
GetModuleFileName(NULL,szFileName,512);
参数为NULL时,得到的是当前进程的目录

解决方案 »

  1.   

    GetCurrentDirectory(...) 是程序运行时当前的路径(可变),不是程序的路径
      

  2.   

    GetModuleFileName 得到了可执行文件名,sFileName, 这样再经过字符串的操作就很容易的得到了该可执行文件所在的目录了,
    GetCurrentDirectory(...) 得到的是当前目录,是不行的
      

  3.   

    char cPath[MAX_PATH];
    CString strPath;GetModualFileName(NULL,cPath,MAX_PATH);
    strPath = cPath;
    strPath = strPath.Left(strPath.ReverseFind('\\'));
    AfxMessageBox(strPath);  // strPath为你想得到的EXE文件路径
      

  4.   

    GetModuleFileName ()DWORD GetModuleFileName(
      HMODULE hModule,    // handle to module
      LPTSTR lpFilename,  // file name of module
      DWORD nSize         // size of buffer
    );
    Parameters
    hModule 
    [in] Handle to the module whose file name is being requested. If this parameter is NULL, GetModuleFileName returns the path for the file containing the current process. 
    lpFilename 
    [out] Pointer to a buffer that receives the path and file name of the specified module. 
    nSize 
    [in] Specifies the length, in TCHARs, of the lpFilename buffer. If the length of the path and file name exceeds this limit, the string is truncated
      

  5.   

    如前面诸位所述,
    GetModuleFileName函数是可以的。如果不是的话,你的意思是说?