Fonction PathIsRootW (shlwapi.h)

Détermine si une chaîne de chemin fait référence à la racine d’un volume.

Syntaxe

BOOL PathIsRootW(
  [in] LPCWSTR pszPath
);

Paramètres

[in] pszPath

Type : LPCTSTR

Pointeur vers une chaîne terminée par null de longueur maximale MAX_PATH qui contient le chemin à valider.

Valeur retournée

Type : BOOL

Retourne TRUE si le chemin spécifié est une racine, ou FALSE dans le cas contraire.

Remarques

Retourne TRUE pour les chemins d’accès tels que « », « X : » ou « \\server\share ». Chemins d’accès tels que .. \path2 » ou « \\server » retourne la valeur FALSE.

Exemples

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

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

// String path name 2.
char buffer_2[ ] = "path\\file";
char *lpStr2;
lpStr2 = buffer_2;

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

// Test case with path not absolute.
retval = PathIsRoot(lpStr1);
cout << "The return from function is       :" << retval << endl;
cout << "The path does contain a root part :" << lpStr1 << endl;

// Test case with path absolute.
retval = PathIsRoot(lpStr2);
cout << "The return from function is       :" << retval << endl;
cout << "The path does not contain part    :" << lpStr2 << endl;
}

OUTPUT:
============
The return from function is       :1
The path does contain a root part :C:\
The return from function is       :0
The path does not contain part    :path\file
============

Notes

L’en-tête shlwapi.h définit PathIsRoot comme un alias qui sélectionne automatiquement la version ANSI ou Unicode de cette fonction en fonction de la définition de la constante de préprocesseur UNICODE. Le mélange de l’utilisation de l’alias neutre en encodage avec du code qui n’est pas neutre en encodage peut entraîner des incompatibilités qui entraînent des erreurs de compilation ou d’exécution. Pour plus d’informations, consultez Conventions pour les prototypes de fonction.

Configuration requise

Condition requise Valeur
Client minimal pris en charge Windows 2000 Professionnel, Windows XP [applications de bureau uniquement]
Serveur minimal pris en charge Windows 2000 Server [applications de bureau uniquement]
Plateforme cible Windows
En-tête shlwapi.h
Bibliothèque Shlwapi.lib
DLL Shlwapi.dll (version 4.71 ou ultérieure)