VC中得到当前路径的方法

得到运行程序所在路径:(其实得到的是当前执行程序存放路径)。

       TCHAR szFilePath[MAX_PATH + 1];

       GetModuleFileName(NULL, szFilePath, MAX_PATH);      

       (_tcsrchr(szFilePath, _T('\\')))[1] = 0;

       CString strtemp=szFilePath;

 

 

 

 

函数说明:

GetModuleFileName:The GetModuleFileName function retrieves the full path and filename for the executable file containing the specified module.

得到程序当前工作路径:(因为程序在运行过程中,会改变工作路径)

       char pBuf[MAX_PATH];                                 //存放路径的变量      

       GetCurrentDirectory(MAX_PATH,pBuf);                   //获取程序的当前目录

       strcat(pBuf,"\\");

       CString strtemp=pBuf;

 

 

函数说明:

GetCurrentDirectoryThe GetCurrentDirectory function retrieves the current directory for the current process

posted on 2010-08-21 13:43 wrh 阅读(1763) 评论(0)  编辑 收藏 引用


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理


导航

<2010年8月>
25262728293031
1234567
891011121314
15161718192021
22232425262728
2930311234

统计

常用链接

留言簿(19)

随笔档案

文章档案

收藏夹

搜索

最新评论

阅读排行榜

评论排行榜