获得当前进程的文件路径"\\"显示

来源:互联网 发布:网络征文2016 编辑:程序博客网 时间:2024/05/17 03:48
 CString str,str1;CString strAppPath;  // 保存结果TCHAR szModuleFileName[MAX_PATH]; // 全路径名TCHAR drive[_MAX_DRIVE];  // 盘符名称,比如说C盘啊,D盘啊TCHAR dir[_MAX_DIR]; // 目录TCHAR fname[_MAX_FNAME];  // 进程名字TCHAR ext[_MAX_EXT]; //后缀,一般为exe或者是dllif ( GetModuleFileName(NULL, szModuleFileName, MAX_PATH)!=NULL) //获得当前进程的文件路径{char *result = NULL;char *buf=NULL;_tsplitpath_s( szModuleFileName, drive, dir, fname, ext );  //分割该路径,得到盘符,目录,文件名,后缀名result = strtok_s( dir, "\\",&buf );while (result!=0){str.Format("%s\\\\",result);str1+=str;result = strtok_s( NULL, "\\",&buf );}strAppPath.Format("%s\\\\",drive);strAppPath+=str1;AfxMessageBox(strAppPath);}

0 0
原创粉丝点击