WNetGetResourceInformation

[This is preliminary documentation and subject to change.]

When provided with a remote path to a network resource, the WNetGetResourceInformation function identifies the network provider that owns the resource and obtains information about the type of the resource. The function is typically used in conjunction with WNetGetResourceParent to parse and interpret a network path typed in by a user.

DWORD WNetGetResourceInformation (
  LPNETRESOURCE lpNetResource,  // Specifies the network resource 
                                // for which information is required
  LPVOID lpBuffer,              // Species a buffer to contain 
                                // the information
  LPDWORD lpcbBuffer,           // Specifies the size of the buffer
                                // pointed to by lpBuffer
  LPTSTR *lplpSystem            // Pointer to a string in the 
                                // output buffer
  );
 

Parameters

lpNetResource
Specifies the network resource for which information is required. The lpRemoteName parameter specifies the remote path name of the resource, typically typed in by a user. The lpProvider and dwType fields should be filled in if known, because this operation can be expensive, especially without dwType. Otherwise, they should be set to NULL. All other fields of lpNetResource are ignored.
lpBuffer
Pointer to the buffer to receive the result. On a successful return, the first field in the buffer is a NETRESOURCE structure representing that portion of the input resource path that is accessed through Windows networking functions, rather than system functions specific to the input resource type. For example, if the input remote resource path was \\server\share\dir1\dir2, then the output NETRESOURCE contains information about the resource \\server\share. The \dir1\dir2 portion of the path is accessed through file functions. The lpRemoteName, lpProvider, dwType, dwDisplayType, and dwUsage fields of NETRESOURCE are returned, with all other fields being set to NULL.

The lpRemoteName parameter is returned in the same syntax as that returned from an enumeration by the WNetEnumResource function. This allows the caller to perform a string comparison to determine whether the resource passed to WNetGetResourceInformation is the same as the resource returned by a separate call to WNetEnumResource.

lpcbBuffer
Pointer to a location that, on entry, specifies the size, in bytes, of the buffer pointed to by lpBuffer. If the buffer is too small for the result, the function places the required buffer size at this location and returns the error ERROR_MORE_DATA.
lplpSystem
If the function returns successfully, lplpSystem points to a string in the output buffer that specifies the part of the resource that is accessed through system functions. This applies only to functions specific to the resource type rather than Windows networking functions.

For example, if the input remote resource name was \\server\share\dir1\dir2, the lpRemoteName parameter of the output NETRESOURCE structure points to \\server\share. Also, the lplpSystem parameter points to \dir1\dir2. Both strings are stored in the buffer pointed to by lpBuffer.

Return Values

If the function succeeds, the return value is NO_ERROR.

If the function fails, the return value is one of the following error codes

Value Meaning
ERROR_BAD_NET_NAME The lpRemoteName parameter is not an existing network resource for any network.
ERROR_BAD_DEV_TYPE The dwType parameter does not match the type of the resource specified by lpRemoteName.
ERROR_EXTENDED_ERROR A network-specific error occurred. Call WNetGetLastError to obtain a description of the error.
ERROR_MORE_DATA The buffer pointed to by lpBuffer is too small.
ERROR_NO_NETWORK The network is not present.

  Header: Declared in winnetwk.h.
  Import Library: Link with mpr.lib.

QuickInfo

  Windows NT: Use version 3.5 or later.
  Windows: Use Windows 95 or later.
  Windows CE: Use version 2.0 or later.
  Header: Declared in winnetwk.h.
  Import Library: Use mpr.lib.

See Also

Windows Networking (WNet) Overview, Windows Networking Functions, WNetGetResourceParent