Partager via


PathIsURLW, fonction (shlwapi.h)

Teste une chaîne donnée pour déterminer si elle est conforme à un format d’URL valide.

Syntaxe

BOOL PathIsURLW(
  [in] LPCWSTR pszPath
);

Paramètres

[in] pszPath

Type : LPCTSTR

Pointeur vers une chaîne terminée par un caractère Null de longueur maximale MAX_PATH qui contient le chemin d’URL à valider.

Valeur retournée

Type : BOOL

Retourne TRUE si pszPath a un format d’URL valide, ou FALSE dans le cas contraire.

Remarques

Cette fonction ne vérifie pas que le chemin pointe vers un site existant, mais seulement qu’il a un format d’URL valide.

Exemples

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

void main( void )
{
// String path name 1.
char buffer_1[ ] = "http://www.microsoft.com/software/index.html";
char *lpStr1;
lpStr1 = buffer_1;

// String path name 2.
char buffer_2[ ] = "http://www.microsoft.com";
char *lpStr2;
lpStr2 = buffer_2;

// String path name 3.
char buffer_3[ ] = "microsoft.com";
char *lpStr3;
lpStr3 = buffer_3;

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

// Test path name 1.
retval = PathIsURL(lpStr1);
cout << "The contents of String 1: " << lpStr1
     << "\nThe return value from the function is " << retval << " = TRUE" << endl;

// Test path name 2.
retval = PathIsURL(lpStr2);
cout << "The contents of String 2: " << lpStr2
     << "\nThe return value from the function is " << retval << " = TRUE" << endl;

// Test path name 3.
retval = PathIsURL(lpStr3);
cout << "The contents of String 3: " << lpStr3
     << "\nThe return value from the function is " << retval << " = FALSE"<< endl;
}

OUTPUT:
=============
The contents of String 1: http://www.microsoft.com/software/index.html
The return value from the function is 1 = TRUE
The contents of String 2: http://www.microsoft.com
The return value from the function is 1 = TRUE
The contents of String 3: microsoft.com
The return value from the function is 0 = FALSE

Notes

L’en-tête shlwapi.h définit PathIsURL en tant qu’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. La combinaison 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

   
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)