Contents Index Topic Contents | ||
Previous Topic: PathFindExtension Next Topic: PathFindNextComponent |
PathFindFileName
LPTSTR PathFindFileName( LPCTSTR pPath );Searches a path for a file name.
- Returns a pointer to the address of the string if successful, or a pointer to the beginning of the path otherwise.
- pPath
- Address of the file name for which to search.
Example:
#include <windows.h> #include <iostream.h> #include "Shlwapi.h" void main( void ) { // Path that contains a file part. char buffer_1[] = "c:\\path\\file"; char *lpStr1; lpStr1 = buffer_1; cout << "Search for the file in path " << lpStr1 << "\nReturns the file part of the path \"" << PathFindFileName(lpStr1) << "\"" << endl; cout << "\nSearch for the file in path \"c:\\path\"" << endl; cout << "Returns the file part of the path \"" << PathFindFileName("c:\\path") << "\"" << endl; cout << "\nSearch for the file in path \"c:\\path\\\"" << endl; cout << "Returns the file part of the path \"" << PathFindFileName("c:\\path\\") << "\"" << endl; cout << "\nSearch for the file in path \"c:\\\"" << endl; cout << "Returns the file part of the path \"" << PathFindFileName("c:\\") << "\"" << endl; cout << "\nSearch for the file in path \"c:\"" << endl; cout << "Returns the file part of the path \"" << PathFindFileName("c:") << "\"" << endl; cout << "\nSearch for the file in path \"path\"" << endl; cout << "Returns the file part of the path \"" << PathFindFileName("path") << "\"" << endl; } OUTPUT: ========== Search for the file in path c:\path\file Returns the file part of the path "file" Search for the file in path "c:\path" Returns the file part of the path "path" Search for the file in path "c:\path\" Returns the file part of the path "path\" Search for the file in path "c:\" Returns the file part of the path "c:\" Search for the file in path "c:" Returns the file part of the path "c:" Search for the file in path "path" Returns the file part of the path "path"
Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.