SHValidateUNC function (shlobj_core.h)

[SHValidateUNC is available for use in the operating systems specified in the Requirements section. It may be altered or unavailable in subsequent versions.]

Validates a Universal Naming Convention (UNC) path by calling WNetAddConnection3. The function makes it possible for the user to type a remote network access (RNA) UNC application or document name from the Run dialog box on the Start menu.

Syntax

BOOL SHValidateUNC(
  [in, optional] HWND  hwndOwner,
  [in, out]      PWSTR pszFile,
                 UINT  fConnect
);

Parameters

[in, optional] hwndOwner

Type: HWND

Handle of the parent window, used to display UI. If this is not needed, this value can be set to NULL.

[in, out] pszFile

Type: PWSTR

A pointer to a null-terminated Unicode string that specifies the UNC path to validate. Note: This string must not be a constant string.

fConnect

Type: UINT

One or more of the following values.

VALIDATEUNC_CONNECT (0x0001)

Connect a drive letter. When this flag is set, the value in pszFile is changed to the local drive to which the UNC is mapped on the local machine.

VALIDATEUNC_NOUI (0x0002)

On either failure or success, display no UI.

VALIDATEUNC_PRINT (0x0004)

Validate as a print share rather than disk share.

VALIDATEUNC_PERSIST (0x0008)

Windows Vista and later. The connection should be made persistent.

VALIDATEUNC_VALID

Mask value used to verify that the flags passed to SHValidateUNC are valid.

Return value

Type: BOOL

Returns TRUE if the UNC path exists; FALSE if the UNC path does not exist or if some other failure occurred.

Requirements

Requirement Value
Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header shlobj_core.h (include Shlobj.h)
Library Shell32.lib
DLL Shell32.dll (version 5.00 or later)