请问:如何得到程序当前的的工作路径和缺省路径?

解决方案 »

  1.   

    当前路径:GetCurrentDirectory()
    缺省路径:指.exe所在路径?GetModuleFileName()
      

  2.   

    TCHAR Path [MAX_PATH];
    GetModuleFileName(NULL, Path,MAX_PATH);
    得到程序的当前路径,包括程序名。
    缺省路径估计你是想要
    GetSystemDirectory(LPTSTR  buffer, UINT size);    //得到系统32路径
    GetWindowsDirectory(.. ..);                   //得到windows路径
      

  3.   

    随便回下,不知道符合你的要求不
    _pgmptr可以返回当前程序的完整路径,比如程序名是a.exe,路径是d:\
    则_pgmptr的内容就是d:\a.exe,通过它就可以分离出工作路径,至于缺省路径,不知道楼主何谓缺省路径
      

  4.   

    BOOL GetCurrentPath()
    {
    DWORD ret;
    char FullPath[261];
    ret = GetModuleFileName(NULL,FullPath,260);
    if ( !ret )
    return FALSE; g_CurrentPath = FullPath;
    int index = g_CurrentPath.ReverseFind('\\');
    g_CurrentPath = g_CurrentPath.Left(index+1); return TRUE;
    }