NPGetResourceInformation function

Separates the part of a network resource accessed through the WNet API from the part accessed through APIs specific to the resource type.


DWORD NPGetResourceInformation(
  _In_    LPNETRESOURCE lpNetResource,
  _Out_   LPVOID        lpBuffer,
  _Inout_ LPDWORD       lpcbBuffer,
  _Out_   LPTSTR        *lplpSystem


lpNetResource [in]

Specifies the network resource for which information is required. The lpRemoteName field specifies the remote name of the resource. The calling program should fill in the values for the lpProvider and dwType fields if it knows these values; otherwise, it should set these fields to NULL. All other fields in the NETRESOURCE are ignored and are not initialized.

If the lpRemoteName string contains a portion that is accessed through WNet APIs and a portion that is accessed through other system APIs specific to the resource type, the function should return information only about the network portion of the resource (except for lplpSystem, as described later in this topic).

For example, if the resource is "\\server\share\dir1\dir2", where "\\server\share" is accessed through WNet APIs and "\dir1\dir2" is accessed through file system APIs, the provider should verify that it is the right provider for "\\server\share", but need not check whether "\dir1\dir2" actually exists.

lpBuffer [out]

Pointer to the buffer to receive the result. The first field in the result is a single NETRESOURCE structure, and associated strings, representing that portion of the input resource that is accessed through the WNet API, rather than system APIs specific to the resource type. For example, if the input remote resource name was "\\server\share\dir1\dir2", then the output NETRESOURCE contains information about the resource "\\server\share". The lpRemoteName, lpProvider, dwType, dwDisplayType, and dwUsage fields are returned containing values, all other fields being set to NULL.

The lpRemoteName field should be returned in the same format as that returned from an enumeration by the NPEnumResource function, so that the caller can perform a case-sensitive string comparison. This is necessary to determine whether the output network resource is the same as one returned by NPEnumResource.

The provider should not do purely syntactic checking to determine whether it owns the resource. This could produce incorrect results when two networks are running on the client and the provider doing syntactic checking is called first.

lpcbBuffer [in, out]

Pointer to a location that 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 WN_MORE_DATA.

lplpSystem [out]

On a successful return, a pointer to a null-terminated string in the output buffer specifying that part of the resource that is accessed through system APIs specific to the resource type, rather than through the WNet API. If there is no such part, lplpSystem is set to NULL. For example, if the input remote resource name was "\\server\share\dir", lpRemoteName is returned pointing to "\\server\share" and lplpSystem points to "\dir", both strings being stored in the buffer pointed to by lpBuffer.

Return value

If the function succeeds, it should return WN_SUCCESS. Otherwise, it should return an error code, which may be one of the following.

Return codeDescription

The input buffer is too small.


The resource is not recognized by this provider.


Invalid dwUsage or dwType.


The caller passed in a nonzero dwType that does not match the actual type of the network resource.


The caller has not been authenticated to the network.


The caller has been authenticated to the network but does not have sufficient permissions.



The enumeration tree can be navigated down from a named network resource by using NPOpenEnum and its related functions. To navigate up from a named resource, the NPGetResourceInformation function can be called to obtain information about the resource, followed by the NPGetResourceParent function to obtain the name and type of the parent resource.

NPGetResourceInformation determines whether the specified provider is the right provider to respond to a request for a specified network resource. It then returns information about the resource's type.


Minimum supported client

Windows XP [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]