Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

PathIsRelative function

Searches a path and determines if it is relative.

Syntax


BOOL PathIsRelative(
  _In_  LPCTSTR lpszPath
);

Parameters

lpszPath [in]

Type: LPCTSTR

A pointer to a null-terminated string of maximum length MAX_PATH that contains the path to search.

Return value

Type: BOOL

Returns TRUE if the path is relative, or FALSE if it is absolute.

Examples


#include <windows.h>
#include <iostream.h>
#include "Shlwapi.h"

void main( void )
{
// String path name 1.
char buffer_1[ ] = "test.exe";
char *lpStr1;
lpStr1 = buffer_1;

// String path name 2.
char buffer_2[ ] = "C:\\test.exe";
char *lpStr2;
lpStr2 = buffer_2;

// Variable to get the return from "PathIsRelative".
int retval;

// Test case with path not absolute.
retval = PathIsRelative(lpStr1);
cout << "The return from function is :" << retval << endl;
cout << "The path is not absolute :   " << lpStr1 << endl;

// Test case with path absolute.
retval = PathIsRelative(lpStr2);
cout << "\nThe return from function is :" << retval << endl;
cout << "The path is absolute :       " << lpStr2 << endl;
}

OUTPUT:
==========
The return from function is :1
The path is not absolute :   test.exe

The return from function is :0
The path is absolute :       C:\test.exe
				

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

PathIsRelativeW (Unicode) and PathIsRelativeA (ANSI)

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.