Export (0) Print
Expand All
2 out of 2 rated this helpful - Rate this topic

PathIsUNC function

Determines if a path string is a valid Universal Naming Convention (UNC) path, as opposed to a path based on a drive letter.

Syntax


BOOL PathIsUNC(
  _In_  LPCTSTR pszPath
);

Parameters

pszPath [in]

Type: LPCTSTR

A pointer to a null-terminated string of maximum length MAX_PATH that contains the path to validate.

Return value

Type: BOOL

Returns TRUE if the string is a valid UNC path; otherwise, FALSE.

Examples

This example feeds sample strings to the PathIsUNC function to demonstrate its return value.


#include "stdafx.h"
#include "shlwapi.h"  // PathIsUNC

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";
    
    int retval = -1;
    
    for (int i = 0; i < 11; i++)
    {
        retval = PathIsUNC(TestStr[i]);
    }
    
    return 0;
}

This table summarizes the results of the code above.

PathPathIsUNC
"\\path1\path2"TRUE
"\\path1"TRUE
"acme\\path4\\path5"FALSE
"\\"TRUE
"\\?\UNC\path1\path2"TRUE
"\\?\UNC\path1"TRUE
"\\?\UNC\"TRUE
"\path1"FALSE
"path1"FALSE
"c:\path1"FALSE
"\\?\c:\path1"FALSE

 

Requirements

Minimum supported client

Windows 2000 Professional, Windows XP [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Shlwapi.h

Library

Shlwapi.lib

DLL

Shlwapi.dll (version 4.71 or later)

Unicode and ANSI names

PathIsUNCW (Unicode) and PathIsUNCA (ANSI)

See also

PathIsUNCEx

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.