Partager via


Fonction PathGetArgsW (shlwapi.h)

Recherche les arguments de ligne de commande dans un chemin donné.

Syntaxe

LPCWSTR PathGetArgsW(
  [in] LPCWSTR pszPath
);

Paramètres

[in] pszPath

Type : PTSTR

Pointeur vers une chaîne terminée par null de longueur maximale MAX_PATH qui contient le chemin d’accès à rechercher.

Valeur retournée

Type : PTSTR

Retourne un pointeur vers une chaîne terminée par null qui contient la partie arguments du chemin en cas de réussite.

S’il n’y a pas d’arguments dans le chemin d’accès, la fonction retourne un pointeur vers la fin de la chaîne d’entrée.

Si la fonction reçoit un argument NULL , elle retourne NULL.

Remarques

Cette fonction ne doit pas être utilisée sur des modèles de chemin de commande génériques (à partir d’utilisateurs ou du Registre), mais doit être utilisée uniquement sur des modèles que l’application sait être bien formés.

Exemples


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

void main( void )
{
    // Path_1 to search for file arguments (2 arguments):
    char buffer_1[ ] = "test.exe temp.txt sample.doc"; 
    char *lpStr1;
    lpStr1 = buffer_1;
    
    // Path_2 to search for file arguments (3 arguments):
    char buffer_2[ ] = "test.exe 1 2 3"; 
    char *lpStr2;
    lpStr2 = buffer_2;
    
    // Path_3 to search for file arguments (3 arguments):
    char buffer_3[ ] = "test.exe sample All 15"; 
    char *lpStr3;
    lpStr3 = buffer_3;
    
    // Path_4 to search for file arguments (no arguments):
    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      :
===========

Notes

L’en-tête shlwapi.h définit PathGetArgs 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)