Platform SDK: Windows Networking |
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 );
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.
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.
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.
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. |
For a code sample that illustrates how to use the WNetGetResourceInformation function, see Retrieving Information About a Network Resource.
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.
Windows Networking (WNet) Overview, Windows Networking Functions, WNetGetResourceParent, WNetGetProviderName, WNetGetNetworkInformation WNetGetUniversalName