词条 | PathFileExists |
释义 | PathFileExists功能 Determines whether a path to a file system object such as a file or directory is valid.确定一个文件或目录的文件系统对象的路径是否是有效的。 Syntax语法BOOL PathFileExists ( __in LPCTSTR pszPath ); Parameters参数 pszPath[in] 类型:LPCTSTR A pointer to a null-terminated string of maximum length MAX_PATH that contains the full path of the object to verify. 最大长度为MAX_PATH的不含'\\0'的字符串指针,包含要验证的完整路径。 Return Value返回值类型:BOOL Returns TRUEif the file exists, or FALSEotherwise.如果该文件存在返回TRUE,否则返回false Remarks备注This function tests the validity of the path.这个函数测试路径的有效性。 A path specified by Universal Naming Convention (UNC) is limited to a file only; that is, \\\\server\\share\\file is permitted.由通用命名约定(UNC)指定的路径是仅限于文件只,也就是说,\\ \\服务器\\共享\\文件是允许的。 A UNC path to a server or server share is not permitted; that is, \\\\ serveror \\\\ server\\ share.一个UNC路径到服务器或服务器共享是不允许的,也就是说,\\ \\ 服务器或\\ \\ 服务器\\ 共享。 This function returns FALSEif a mounted remote drive is out of service.该函数返回FALSE,如果安装远程驱动器是出于服务。 Examples举例Copy复制 #include <iostream.h> #include "Shlwapi.h" #pragma comment(lib,"Shlwapi.lib") /*需要加上此行才可以正确link,VC6.0*/ void main(void) { char buffer_1[ ] = "C:\\\\TEST\\\\file.txt"; //有效的文件路径名(文件存在) char *lpStr1; lpStr1 = buffer_1; char buffer_2[ ] = "C:\\\\TEST\\\\file.doc";// 无效的文件路径名(文件不存在) char *lpStr2; lpStr2 = buffer_2; int retval; //从“PathFileExists”返回值。 retval = PathFileExists(lpStr1); if(retval == 1) { cout << "Search for the file path of : " << lpStr1 << endl; cout << "The file requested \\"" << lpStr1 << "\\" is a valid file" << endl; cout << "The return from function is : " << retval << endl; } else{ cout << "\The file requested " << lpStr1 << " is not a valid file" << endl; cout << "The return from function is : " << retval << endl; } retval = PathFileExists(lpStr2); if(retval == 1) { cout << "\The file requested " << lpStr2 << "is a valid file" << endl; cout << "Search for the file path of : " << lpStr2 << endl; cout << "The return from function is : " << retval << endl; } else { cout << "\The file requested \\"" << lpStr2 << "\\" is not a valid file" << endl; cout << "The return from function is : " << retval << endl; } } //OUTPUT============== ============== //Search for the file path of : C:\\TEST\\file.txt //The file requested "C:\\TEST\\file.txt" is a valid file //The return from function is : 1 //The file requested "C:\\TEST\\file.doc" is not a valid file //The return from function is : 0 Requirements要求Minimum supported client最低支持的客户端 Windows 2000 Professional, Windows XP的Windows 2000专业版,Windows XP Minimum supported server最低支持的服务器 Windows 2000 Server Windows 2000服务器 Header头 Shlwapi.h Shlwapi.h Library图书馆 Shlwapi.lib Shlwapi.lib DLL DLL Shlwapi.dll (version 4.71 or later) SHLWAPI.DLL(版本4.71或更高版本) Unicode and ANSI names Unicode和ANSI名称 PathFileExistsW(Unicode) and PathFileExistsA(ANSI) PathFileExistsW(Unicode)和PathFileExistsA(ANSI) |
随便看 |
百科全书收录4421916条中文百科知识,基本涵盖了大多数领域的百科知识,是一部内容开放、自由的电子版百科全书。