PathIsUNCEx function
Determines if a path string is a valid Universal Naming Convention (UNC) path, as opposed to a path based on a drive letter.
This function differs from PathIsUNC in that it also allows you to extract the name of the server from the path.
Syntax
BOOL PathIsUNCEx( _In_ PCWSTR pszPath, _Out_opt_ PCWSTR *ppszServer );
Parameters
- pszPath [in]
-
A pointer to the path string.
- ppszServer [out, optional]
-
A pointer to a string that, when this function returns successfully, receives the server portion of the UNC path. This value can be NULL if you don't need this information.
Return value
Returns TRUE if the string is a valid UNC path; otherwise, FALSE.
Examples
This example feeds sample strings to the PathIsUNCEx function to demonstrate its return values.
#include "stdafx.h" #include "pathcch.h" // PathIsUNCEx int _tmain(int argc, _TCHAR* argv[]) { PCWSTR TestStr[11]; // Test strings TestStr[0] = L"\\\\path1\\path2"; TestStr[1] = L"\\\\path1"; TestStr[2] = L"acme\\path4\\path5"; TestStr[3] = L"\\\\"; TestStr[4] = L"\\\\?\\UNC\\path1\\path2"; TestStr[5] = L"\\\\?\\UNC\\path1"; TestStr[6] = L"\\\\?\\UNC\\"; TestStr[7] = L"\\path1"; TestStr[8] = L"path1"; TestStr[9] = L"c:\\path1"; TestStr[10] = L"\\\\?\\c:\\path1"; BOOL retval2 = FALSE; PCWSTR ServerStr; for (int i = 0; i < 11; i++) { retval2 = PathIsUNCEx(TestStr[i], &ServerStr); } return 0; }
This table summarizes the results of the code above.
| Path | PathIsUNCEx | ServerStr |
|---|---|---|
| "\\path1\path2" | TRUE | "path1\\path2" |
| "\\path1" | TRUE | "path1" |
| "acme\\path4\\path5" | FALSE | NULL |
| "\\" | TRUE | "" |
| "\\?\UNC\path1\path2" | TRUE | "path1\\Path2" |
| "\\?\UNC\path1" | TRUE | "path1" |
| "\\?\UNC\" | TRUE | "" |
| "\path1" | FALSE | NULL |
| "path1" | FALSE | NULL |
| "c:\path1" | FALSE | NULL |
| "\\?\c:\path1" | FALSE | NULL |
Requirements
|
Minimum supported client |
Windows 8 [desktop apps only] |
|---|---|
|
Minimum supported server |
Windows Server 2012 [desktop apps only] |
|
Header |
|
|
Library |
|