您的位置:首页 > 其它

PathFileExists用法--使用#include <shlwapi.h>

2015-07-02 16:32 459 查看
BOOL PathFileExists(LPCTSTR pszPath);

Determines if a file exists.

---经检测,该函数可以检测文件或目录是否存在

Remarks

This function tests the validity of the file and path. It works only on the local file system or on a remote drive that has been mounted to a drive letter. It will return FALSE for remote file paths that begin with the UNC names \\server or \\server\share.
It will also return FALSE if a mounted remote drive is out of service.

为了使用PathFileExists(),必须包含头文件"shlwapi.h",范例代码如下:

编译后,却发现一个错误:error LNK2001: unresolved external symbol
__imp__PathFileExistsA@4


网上搜索了下,发现是因为没有添加相应的lib。添加lib的方法网上有不少,这里使用下面的方法:

或者在文件头部加入这行代码: #pragma comment(lib,"shlwapi.lib")





这样,就可以通过编译了!


                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: