Condividi tramite


Funzione PathGetArgsA (shlwapi.h)

Trova gli argomenti della riga di comando all'interno di un determinato percorso.

Sintassi

LPCSTR PathGetArgsA(
  [in] LPCSTR pszPath
);

Parametri

[in] pszPath

Tipo: PTSTR

Puntatore a una stringa con terminazione Null con lunghezza massima MAX_PATH contenente il percorso da cercare.

Valore restituito

Tipo: PTSTR

Restituisce un puntatore a una stringa con terminazione Null che contiene la parte degli argomenti del percorso, se ha esito positivo.

Se nel percorso non sono presenti argomenti, la funzione restituisce un puntatore alla fine della stringa di input.

Se alla funzione viene assegnato un argomento NULL , restituisce NULL.

Commenti

Questa funzione non deve essere usata nei modelli di percorso di comando generici (da utenti o registro), ma deve essere usata solo nei modelli che l'applicazione sa essere ben formata.

Esempi


#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      :
===========

Nota

L'intestazione shlwapi.h definisce PathGetArgs come alias che seleziona automaticamente la versione ANSI o Unicode di questa funzione in base alla definizione della costante del preprocessore UNICODE. La combinazione dell'utilizzo dell'alias indipendente dalla codifica con il codice che non è indipendente dalla codifica può causare mancate corrispondenze che generano errori di compilazione o di runtime. Per altre informazioni, vedere Convenzioni per i prototipi di funzioni.

Requisiti

Requisito Valore
Client minimo supportato Windows 2000 Professional, Windows XP [solo app desktop]
Server minimo supportato Windows 2000 Server [solo app desktop]
Piattaforma di destinazione Windows
Intestazione shlwapi.h
Libreria Shlwapi.lib
DLL Shlwapi.dll (versione 4.71 o successiva)