Contents Index Topic Contents | ||
Previous Topic: PathIsRoot Next Topic: PathIsSystemFolder |
PathIsSameRoot
BOOL PathIsSameRoot( LPCTSTR pszPath1, LPCTSTR pszPath2 );Compares two paths to determine if they have a common root component.
- Returns TRUE if both strings have the same root component, or FALSE otherwise.
- pszPath1
- Address of the first path to be compared.
- pszPath2
- Address of the second path to be compared.
Example:
#include <windows.h> #include <iostream.h> #include "Shlwapi.h" void main( void ) { // String path name 1. char buffer_1[] = "C:\\path1\\one"; char *lpStr1; lpStr1 = buffer_1; // String path name 2. char buffer_2[] = "C:\\path2\\two"; char *lpStr2; lpStr2 = buffer_2; // Variable to get the // return from "PathIsSameRoot". int retval; // Compare paths with same root. retval = PathIsSameRoot(lpStr1,lpStr2); cout << "The return from function is : " << retval << endl; cout << "The contents of String 1: " << lpStr1 << "\nThe contents of String 2: " << lpStr2 << "\nThese both have the same root part" << endl; //compare paths with different roots retval = PathIsSameRoot(lpStr1,"E:\\acme\\three"); cout << "\nThe return from function is : " << retval << endl; cout << "The contents of String 1: " << lpStr1 << "\nThe contents of String 3: E:\\acme\\three" << "\nThese do not have the same root part" << endl; } OUTPUT: ================== The return from function is : 1 The contents of String 1: C:\path1\one The contents of String 2: C:\path2\two These both have the same root part The return from function is : 0 The contents of String 1: C:\path1\one The contents of String 3: E:\acme\three These do not have the same root part
Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.