Contents Index Topic Contents | ||
Previous Topic: PathIsHTMLFile Next Topic: PathIsRelative |
PathIsPrefix
BOOL PathIsPrefix( IN LPCTSTR pszPrefix, IN LPCTSTR pszPath );Searches a path to determine if it contains a valid prefix of the type passed by pszPrefix. A prefix is one of these types: "C:\\", ".", "..", "..\\".
- Returns TRUE if the compared path is the full prefix for the path, or FALSE otherwise.
- pszPrefix
- Address of the prefix for which to search.
- pszPath
- Address of the path to be searched.
Example:
#include <windows.h> #include <iostream.h> #include "Shlwapi.h" void main( void ) { // Path prefix 1. char buffer_1[] = "C:\\"; char *lpStr1; lpStr1 = buffer_1; // Path prefix 2. char buffer_2[] = "C:\\test\\Some\\sample"; char *lpStr2; lpStr2 = buffer_2; // Path prefix 3. char buffer_3[] = "sample"; char *lpStr3; lpStr3 = buffer_3; // Search a path prefix with result true. cout << "The contents of path 1 is : " << lpStr1 << "\nThe contents of path 2 is : " << lpStr2 << "\nThe return from the function is : " << PathIsPrefix(lpStr1,lpStr2) << "\nPathIsPrefix returns TRUE " << "\nand Path lpStr1 and lpStr2" << "\nhave the same prefix :" << endl; // Search a path prefix with result false. cout << "\nThe contents of path 1 is : " << lpStr1 << "\nThe contents of path 3 is : " << lpStr3 << "\nThe return from the function is : " << PathIsPrefix(lpStr1,lpStr3) << "\nPathIsPrefix returns FALSE " << "\nand Path lpStr1 and lpStr3" << "\nhave different prefixes :" << endl; } OUTPUT: ============== The contents of path 1 is : C:\ The contents of path 2 is : C:\test\Some\sample The return from the function is : 1 PathIsPrefix returns TRUE and Path lpStr1 and lpStr2 have the same prefix : The contents of path 1 is : C:\ The contents of path 3 is : sample The return from the function is : 0 PathIsPrefix returns FALSE and Path lpStr1 and lpStr3 have different prefixes :
Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.