WNetGetResourceParent

This function can be called to navigate up from a resource, and enables browsing to commence based upon the name of a network resource. It also allows navigating up from a browsed resource to find connectable resources.

WNetGetResourceParent can be called for names that were returned from a call to WNetEnumResource. Unlike WNetGetResourceInformation, if the resource syntactically has a parent, then this is returned by WNetGetResourceParent, whether or not the parent actually exists or not.


DWORD WNetGetResourceParent(
    LPNETRESOURCE lpNetResource,
    LPVOID lpBuffer,
    LPDWORD lpBufferSize
    );

lpNetResource

This specifies the network resource for which the parent name is required. The NETRESOURCE could have been obtained via a previous WNetEnumResource, or constructed by the caller. The lpRemoteName field of the NETRESOURCE specifies the remote name of the network resource whose parent name is required. If the calling program knows the values for the lpProvider, and dwType fields (as it typically should, since it will have previously called WNetGetResourceInformation), then it should fill them in. Otherwise, it should set them to NULL. All other fields in the NETRESOURCE are ignored and do not have to be filled in.

lpBuffer

A pointer to the buffer to receive the result, which is returned as a single NETRESOURCE entry representing the parent resource. The lpRemoteName, lpProvider, dwType and dwUsage fields are returned, all other fields being set to NULL. The remote name returned is in the same syntax as that returned from an enumeration, so that the caller can do a case sensitive string compare to determine whether an enumerated resouce is this resource. The provider name is returned only if it is known which network the resource belongs to. If several networks could own the resource, (as may be the case for a resource such as "\\server"), then lpProvider will be set to NULL. If a resource has no parent on any of the networks, then lpRemoteName is returned as NULL. If it is known that a network owns a parent of the resource, but that the resource itself is not valid, then lpProvider is returned as a non-null value together with a return status of WN_BAD_NETNAME. Note that if a network thinks that the object is on the network, but has no parent (e.g. a server that is not part of a workgroup), then there is the possibility that this API may return with lpRemoteName and lpProvider both set to NULL. The RESOURCEUSAGE_CONNECTABLE value in the dwUsage field does not indicate that the resource can currently be connected to, but that the resource is connectable when it is available on the network.

lpBufferSize

This specifies the size in bytes of the buffer passed to the function call. If the result is WN_MORE_DATA, this will contain the buffer size required (in bytes) to hold the NETRESOURCE information.

WN_MORE_DATA

if input buffer is too small.

WN_BAD_PROVIDER

lpProvider does not match any NP

WN_BAD_NETNAME

lpRemoteName is not a syntactically valid name for a remote resource for any network

WN_NOT_AUTHENTICATED

the caller does not have the necessary permissions to obtain the name of the parent.

WN_ACCESS_DENIED

the user is authenticated to the network, but does not have sufficient permissions (access rights).