WinCE 7.0 下如何获取全路径文件名的后缀?

一般大家会自己用字符串处理函数来获取,我以前也是这样做的。
今天看到一个使用系统 API 获取后缀的方法,使用的是 PathFindExtension()。
这个函数在 MSDN 的智能设备的帮助中竟然没有,但确实是可以在 WinCE 7.0 下使用的。


以下是 MSDN 帮助的内容:
PathFindExtension Function
--------------------------------------------------------------------------------
Searches a path for an extension. 
Syntax
LPTSTR PathFindExtension(LPCTSTR pPath);
Parameters
pPath
[in] A pointer to a null-terminated string of maximum length MAX_PATH that contains the path that contains the extension for which to search.
Return Value
Returns the address of the "." preceding the extension within pPath if an extension is found, or the address of the trailing NULL character otherwise. 


得到的后缀是带 "." 的。
示例代码:
const TCHAR *GetFileExtentionName(LPCTSTR szFileExt)
{
	TCHAR *ptrFile = PathFindExtension(szFileExt);


	return ptrFile + 1;		// 返回不带 "." 的后缀名
}


你可能感兴趣的:(WinCE 7.0 下如何获取全路径文件名的后缀?)