Contents Index Topic Contents | ||
Previous Topic: PathFindOnPath Next Topic: PathGetCharType |
PathGetArgs
LPTSTR PathGetArgs( LPCTSTR pszPath );Finds the command line arguments within a given path.
- Returns the address of the beginning of the command line arguments if successful, or NULL otherwise.
- pszPath
- Address of the path to be searched.
Example:
#include <windows.h> #include <iostream.h> #include "Shlwapi.h" void main( void ) { // Path_1 to search for file arguments (2-Args): char buffer_1[] = "test.exe temp.txt sample.doc"; char *lpStr1; lpStr1 = buffer_1; // Path_2 to search for file arguments (3-Args): char buffer_2[] = "test.exe 1 2 3"; char *lpStr2; lpStr2 = buffer_2; // Path_3 to search for file arguments (3-Args): char buffer_3[] = "test.exe sample All 15"; char *lpStr3; lpStr3 = buffer_3; // Path_4 to search for file arguments (zero args): char buffer_4[] = "test.exe"; char *lpStr4; lpStr4 = buffer_4; cout << "The path passed to the function was : " << lpStr1 << "\nThe arg(s)found in path 1 were : " << PathGetArgs(lpStr1) << endl; cout << "\nThe path passed to the function was : " << lpStr2 << "\nThe arg(s)found in path 2 were : " << PathGetArgs(lpStr2) << endl; cout << "\nThe path passed to the function was : " << lpStr3 << "\nThe arg(s)found in path 3 were : " << PathGetArgs(lpStr3) << endl; cout << "\nThe path passed to the function was : " << lpStr4 << "\nThe arg(s)found in path 4 were : " << PathGetArgs(lpStr4) << endl; } OUTPUT: =========== The path passed to the function was : test.exe temp.txt sample.doc The arg(s)found in path 1 were : temp.txt sample.doc The path passed to the function was : test.exe 1 2 3 The arg(s)found in path 2 were : 1 2 3 The path passed to the function was : test.exe sample All 15 The arg(s)found in path 3 were : sample All 15 The path passed to the function was : test.exe The arg(s)found in path 4 were : ===========
Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.