当前位置:首页 > 芯闻号 > 充电吧
[导读]一般大家会自己用字符串处理函数来获取,我以前也是这样做的。今天看到一个使用系统 API 获取后缀的方法,使用的是 PathFindExtension()。这个函数在 MSDN 的智能设备的帮助中竟然没

一般大家会自己用字符串处理函数来获取,我以前也是这样做的。
今天看到一个使用系统 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;		// 返回不带 "." 的后缀名
}



本站声明: 本文章由作者或相关机构授权发布,目的在于传递更多信息,并不代表本站赞同其观点,本站亦不保证或承诺内容真实性等。需要转载请联系该专栏作者,如若文章内容侵犯您的权益,请及时联系本站删除。
关闭
关闭