Fungsi PathGetArgsA (shlwapi.h)
Menemukan argumen baris perintah dalam jalur tertentu.
LPCSTR PathGetArgsA(
[in] LPCSTR pszPath
);
[in] pszPath
Jenis: PTSTR
Penunjuk ke string panjang maksimum yang dihentikan null MAX_PATH yang berisi jalur yang akan dicari.
Jenis: PTSTR
Mengembalikan penunjuk ke string null-terminated yang berisi bagian argumen dari jalur jika berhasil.
Jika tidak ada argumen di jalur, fungsi mengembalikan penunjuk ke akhir string input.
Jika fungsi diberikan argumen NULL
Fungsi ini tidak boleh digunakan pada templat jalur perintah generik (dari pengguna atau registri), melainkan harus digunakan hanya pada templat yang diketahui aplikasi untuk terbentuk dengan baik.
#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 :
===========
Catatan
Header shlwapi.h mendefinisikan PathGetArgs sebagai alias yang secara otomatis memilih versi ANSI atau Unicode dari fungsi ini berdasarkan definisi konstanta praproscesor UNICODE. Mencampur penggunaan alias encoding-netral dengan kode yang tidak mengodekan-netral dapat menyebabkan ketidakcocokan yang mengakibatkan kesalahan kompilasi atau runtime. Untuk informasi selengkapnya, lihat Konvensi untuk Prototipe Fungsi.
Syarat | Nilai |
---|---|
klien minimum yang didukung | Windows 2000 Professional, Windows XP [hanya aplikasi desktop] |
server minimum yang didukung |
Windows 2000 Server [hanya aplikasi desktop] |
Platform Target |
Windows |
Header |
shlwapi.h |
Pustaka |
Shlwapi.lib |
DLL |
Shlwapi.dll (versi 4.71 atau yang lebih baru) |