Platform SDK: Windows Networking

WNetGetResourceInformation

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 the WNetGetResourceParent function to parse and interpret a network path typed in by a user.

DWORD WNetGetResourceInformation (
  LPNETRESOURCE lpNetResource, // network resource
  LPVOID lpBuffer,             // information buffer
  LPDWORD lpcbBuffer,          // size of information buffer
  LPTSTR *lplpSystem           // string
);

Parameters

lpNetResource
[in] Pointer to a NETRESOURCE structure that specifies the network resource for which information is required.

The lpRemoteName member of the structure should specify the remote path name of the resource, typically one typed in by a user. The lpProvider and dwType members should also be filled in if known, because this operation can be memory intensive, especially if you do not specify the dwType member. If you do not know the values for these members, you should set them to NULL. All other members of the NETRESOURCE structure are ignored.

lpBuffer
[out] Pointer to the buffer to receive the result. On successful return, the first portion of the buffer is a NETRESOURCE structure representing that portion of the input resource path that is accessed through the WNet functions, rather than through system functions specific to the input resource type. (The remainder of the buffer contains the variable-length strings to which the members of the NETRESOURCE structure point.)

For example, if the input remote resource path is \\server\share\dir1\dir2, then the output NETRESOURCE structure contains information about the resource \\server\share. The \dir1\dir2 portion of the path is accessed through the file I/O functions. The lpRemoteName, lpProvider, dwType, dwDisplayType, and dwUsage members of NETRESOURCE are returned, with all other members set to NULL.

The lpRemoteName member is returned in the same syntax as the one 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
[in/out] Pointer to a location that, on entry, specifies the size, in bytes, of the buffer pointed to by lpBuffer. The buffer you allocate must be large enough to hold the NETRESOURCE structure, plus the strings to which its members point. If the buffer is too small for the result, this location receives the required buffer size, and the function returns ERROR_MORE_DATA.
lplpSystem
[out] If the function returns successfully, this parameter 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 the WNet functions.)

For example, if the input remote resource name is \\server\share\dir1\dir2, the lpRemoteName member 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 the lpBuffer parameter.

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 input lpRemoteName member is not an existing network resource for any network.
ERROR_BAD_DEV_TYPE The input dwType member does not match the type of resource specified by the lpRemoteName member.
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 the lpBuffer parameter is too small.
ERROR_NO_NETWORK The network is unavailable.

Remarks

For a code sample that illustrates how to use the WNetGetResourceInformation function, see Retrieving Information About a Network Resource.

Requirements

  Windows NT/2000: Requires Windows NT 4.0 or later.
  Windows 95/98: Requires Windows 95 or later.
  Header: Declared in Winnetwk.h.
  Library: Use Mpr.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.

See Also

Windows Networking (WNet) Overview, Windows Networking Functions, WNetGetResourceParent, WNetGetProviderName, WNetGetNetworkInformation WNetGetUniversalName