首页 > 代码库 > 文件路径获取目录API

文件路径获取目录API

总有这样一个API被人遗忘在角落,

从文件路径获取目录名:
Desc:Removes the trailing file name and backslash from a path, if it has them.
 
Syntax
BOOL PathRemoveFileSpec( LPTSTR pszPath)
 
HEADR:shlwapi.h
 
 

TCHAR PathStr[MAX_PATH];
GetModuleFileName(NULL, PathStr, MAX_PATH);
PathRemoveFileSpecW(PathStr);
CString str;
str.Format(L"%s\\book.mdb", PathStr);

文件路径获取目录API