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

PathIsUNCServer function

Determines if a string is a valid Universal Naming Convention (UNC) for a server path only.

Syntax


BOOL PathIsUNCServer(
  _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 for a server only (no share name), or FALSE otherwise.

Examples


#include <windows.h>
#include <iostream.h>
#include "Shlwapi.h"

void main( void )
{
// String path name 1.
char buffer_1[ ] = "\\\\path1";
char *lpStr1;
lpStr1 = buffer_1;

// String path name 2.
char buffer_2[ ] = "\\\\";
char *lpStr2;
lpStr2 = buffer_2;

// String path name 3.
char buffer_3[ ] = "acme\\path2\\path3";
char *lpStr3;
lpStr3 = buffer_3;

// Variable to get the return 
// from "PathIsUNCServer".
int retval;

// Test path name 1.
retval = PathIsUNCServer(lpStr1);
cout << "The contents of String 1: " << lpStr1
     << "\nThe return value from the function is " << retval << " = TRUE" << endl;

// Test path name 2.
retval = PathIsUNCServer(lpStr2);
cout << "The contents of String 2: " << lpStr2
     << "\nThe return value from the function is " << retval << " = TRUE" << endl;

// Test path name 3.
retval = PathIsUNCServer(lpStr3);
cout << "The contents of String 3: " << lpStr3
     << "\nThe return value from the function is " << retval << " = FALSE"<< endl;
}

OUTPUT:
=================
The contents of String 1: \\path1
The return value from the function is 1 = TRUE
The contents of String 2: \\
The return value from the function is 1 = TRUE
The contents of String 3: acme\path2\path3
The return value from the function is 0 = 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

PathIsUNCServerW (Unicode) and PathIsUNCServerA (ANSI)

 

 

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

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.