程序开始运行时
GetCurrentDirectory()

解决方案 »

  1.   

    我试过这个办法,不过打开文件或者保存文件之后,这个函数的返回值就变了.
    VB 中可以使用 App.Path ,VC中就没有办法了?
      

  2.   

    char strFileName[100];
    GetModuleFileName(NULL,strFileName,100);
    ::MessageBox(NULL,strFileName,"22",MB_OK);
      

  3.   

    这个问题都说啦好几次啦,是seesi的方法,在处理一下,因为它得到的是整个路径和文件名。
      

  4.   

        char szFileFullPath[MAX_PATH];
        ::GetModuleFileName(NULL, szFileFullPath, MAX_PATH);
        CString szFilePath(szFileFullPath);
        int nPos = szFilePath.ReverseFind('\\');
        szFilePath = szFilePath.Left(nPos);
        AfxMessageBox(szFileFullPath);
        AfxMessageBox(szFilePath);
      

  5.   

    或:
    szFilePath = szFilePath.Left(nPos + 1);
      

  6.   

    呵呵,wbc_58(我是我)把VC和DELPHI搞混了吧?
      

  7.   

    自己写的函数,忘记了
    CString CMyDlg::GetExeFilePath()
    {
    TCHAR buffer[1024];
    GetModuleFileName(AfxGetInstanceHandle(),buffer,1024);
    return CString(buffer);
    }
      

  8.   

    怎样得到程序的当前路径
     
     
    #include < windows.h >
    #include < string.h > HINSTANCE hInst;
    char szBuf[256];
    char *p; //拿到全部路径
    GetModuleFileName(hInst,szBuf,sizeof(szBuf)); //分离路径和文件名。
    p = szBuf;
    while(strchr(p,'\\')) {
    p = strchr(p,'\\');
    p++;
    }
    *p = '\0';
    //路径在szBuf理了。