PathStripPath function

Removes the path portion of a fully qualified path and file.

Syntax


void PathStripPath(
  _Inout_  LPTSTR pszPath
);

Parameters

pszPath [in, out]

Type: LPTSTR

A pointer to a null-terminated string of length MAX_PATH that contains the path and file name. When this function returns successfully, the string contains only the file name, with the path removed.

Return value

This function does not return a value.

Examples

The following examples show the effect of PathStripPath on a series of strings.


TCHAR szPath1[] = TEXT("c:\\dir1\\file.txt");
PathStripPath(szPath1);
// Result: szPath1 == file.txt

TCHAR szPath2[] = TEXT("c:\\windows\\system32\\directx\\dinput\\joystick.ini");
PathStripPath(szPath2);
// Result: szPath2 == joystick.ini
    
TCHAR szPath3[] = TEXT("c:\\dir1\\dir2");
PathStripPath(szPath3);
// Result: szPath3 == dir2

TCHAR szPath4[] = TEXT("c:\\dir1\\dir2\\");
PathStripPath(szPath4);
// Result: szPath4 == dir2\

TCHAR szPath5[] = TEXT("c:\\");
PathStripPath(szPath5);
// Result: szPath5 == c:\ (no change)

TCHAR szPath6[] = TEXT("c:");
PathStripPath(szPath6);
// Result: szPath6 == c: (no change)

TCHAR szPath7[] = TEXT("Not a Path");
PathStripPath(szPath7);
// Result: szPath7 == Not a Path (no change)

Requirements

Minimum supported client

Windows 2000 Professional, Windows XP [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Shlwapi.h

Library

Shlwapi.lib

DLL

Shlwapi.dll (version 4.71 or later)

Unicode and ANSI names

PathStripPathW (Unicode) and PathStripPathA (ANSI)

 

 

Community Additions

ADD
Show:
© 2014 Microsoft