Platform SDK: Windows Networking |
The WNetGetResourceParent function returns the parent of a network resource in the network browse hierarchy. Browsing begins at the location of the specified network resource.
Call the WNetGetResourceInformation and WNetGetResourceParent functions to move up the network hierarchy. Call the WNetOpenEnum function to move down the hierarchy.
DWORD WNetGetResourceParent( LPNETRESOURCE lpNetResource, // network resource LPVOID lpBuffer, // buffer LPDWORD lpcbBuffer // buffer size );
Specify the members of the input NETRESOURCE structure as follows. The caller typically knows the values to provide for the lpProvider and dwType members after previous calls to WNetGetResourceInformation or WNetGetResourceParent.
Member | Description |
---|---|
dwType | This member should be filled in if known; otherwise, it should be set to NULL. |
lpRemoteName | This member should specify the remote name of the network resource whose parent is required. |
lpProvider | This member should specify the network provider that owns the resource. This member is required; otherwise, the function could produce incorrect results. |
All other members of the NETRESOURCE structure are ignored.
The lpRemoteName member points to the remote name for the parent resource. This name uses the same syntax as the one returned from an enumeration by the WNetEnumResource function. The caller can perform a string comparison to determine whether the WNetGetResourceParent resource is the same as that returned by WNetEnumResource. If the input resource has no parent on any of the networks, the lpRemoteName member is returned as NULL.
The presence of the RESOURCEUSAGE_CONNECTABLE bit in the dwUsage member indicates that you can connect to the parent resource, but only when it is available on the network.
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_ACCESS_DENIED | The user is authenticated to the network, but does not have sufficient permissions (access rights) to perform the operation. |
ERROR_BAD_NET_NAME | The input lpRemoteName member is not an existing network resource for any network. |
ERROR_BAD_PROVIDER | The input lpProvider member does not match any installed network provider. |
ERROR_MORE_DATA | The buffer pointed to by the lpBuffer parameter is too small. |
ERROR_NOT_AUTHENTICATED | The caller does not have the necessary permissions to obtain the name of the parent. |
The WNetGetResourceParent function is typically used in conjunction with the WNetGetResourceInformation function to parse and interpret a network path typed in by a user.
Unlike the WNetGetResourceInformation function, if the resource includes a parent in its syntax, the WNetGetResourceParent function returns the parent, whether or not the resource actually exists. WNetGetResourceParent should typically be used only by applications that display network resources to the user in a hierarchical fashion. The Windows Explorer and the File Open dialog box are two well-known examples of this type of application. Note that no assumptions should be made about the type of resource that will be returned.
You can call the WNetEnumResource, WNetGetResourceInformation, or WNetGetResourceParent function to return information from the NETRESOURCE structure. You can also construct network resource information using the members of the NETRESOURCE structure.
An example of an inappropriate use of WNetGetResourceParent is to determine the name of the domain to which a specified server belongs. The function may happen to return the correct domain name for some networks in which domains appear directly above servers in the browse hierarchy.The function will return incorrect results for other networks.
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, WNetGetResourceInformation, WNetGetProviderName, WNetGetNetworkInformation, WNetGetUniversalName