Fungsi PathIsURLW (shlwapi.h)
Menguji string tertentu untuk menentukan apakah sesuai dengan format URL yang valid.
BOOL PathIsURLW(
[in] LPCWSTR pszPath
);
[in] pszPath
Jenis:
Penunjuk ke string panjang maksimum yang dihentikan null MAX_PATH yang berisi jalur URL untuk divalidasi.
Jenis: BOOL
Mengembalikan TRUE
Fungsi ini tidak memverifikasi bahwa jalur menunjuk ke situs yang ada—hanya memiliki format URL yang valid.
#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
Catatan
Header shlwapi.h mendefinisikan PathIsURL sebagai alias yang secara otomatis memilih versi ANSI atau Unicode dari fungsi ini berdasarkan definisi konstanta preprosektor 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) |