This API is used to open an enumeration of network resources or existing connections. It must be called to obtain a valid handle for enumeration.
DWORD WNetOpenEnum (
DWORD dwScope,
DWORD dwType,
DWORD dwUsage,
LPNETRESOURCE lpNetResource,
LPHANDLE lphEnum
);
RESOURCE_CONNECTED | All currently connected resources - this does not include persistent connections that are not currently available. |
RESOURCE_GLOBALNET | All resources on the network. |
RESOURCE_REMEMBERED | All persistent connections. |
RESOURCE_RECENT | The most recent connections made. |
RESOURCE_CONTEXT | The resources associated with the user's current and default network context. |
RESOURCETYPE_DISK | All disk resources. |
RESOURCETYPE_PRINT | All print resources. |
If dwType is RESOURCETYPE_ANY, all types of resources are returned. If an NP does not have the capability to distinguish between print and disk resources at a level, it may return all resources.
RESOURCEUSAGE_CONNECTABLE | All connectable resources. |
RESOURCEUSAGE_CONTAINER | All container resources. |
RESOURCEUSAGE_ALL | All resources. |
This field is ignored if dwScope is not RESOURCE_GLOBALNET.
WN_NOT_SUPPORTED | this call is specifically returned when lpNetResource specifies a provider, dwScope is RESOURCE_GLOBALNET, and the specified provider does not support browsing. |
WN_NOT_CONTAINER | lpNetResource does not point to a container |
WN_BAD_VALUE | Invalid dwScope or dwUsage or dwType, or bad combination of parameters is specified. |
WN_FUNCTION_BUSY | The MPR or NP is busy (possibly initializing). The caller should retry. |
WN_NO_NETWORK | network is not present |
WN_EXTENDED_ERROR | a network specific error occurred. WNetGetLastError should be called to obtain a description of the error. |
WN_NOT_AUTHENTICATED | authentication needs to occur before the network resource can be enumerated. |
WN_NOT_LOGGED_ON | a system logon needs to occur before network enumeration is possible. |
WN_ACCESS_DENIED | the user is authenticated to the network where the enumeration is being attempted, but does not have sufficient permissions (access rights). |
If dwScope is set to RESOURCE_GLOBALNET and the lpNetResource parameter is NULL, each NETRESOURCE structure in the returned buffer will describe a network. Each entry's lpRemoteName field will be NULL (indicating the logical root of that network), and its lpProvider field will name the network. Passing such a NETRESOURCE to a further WNetOpenEnum will enumerate the top level of that particular network.
If dwScope is set to RESOURCE_CONTEXT, each NETRESOURCE structure in the returned buffer will describe a network resource that could be from any part of a network's global browse hierarchy. In addition, the first NETRESOURCE structure in the returned buffer represents a logical root for the network, and performing a WNetOpenEnum on this NETRESOURCE will enumerate the networks in the same way as above. Specifically, the NETRESOURCE structure has the following settings:
dwScope is RESOURCE_GLOBALNET | |
dwType is RESOURCETYPE_ANY | |
dwDisplayType is RESOURCEDISPLAYTYPE_ROOT | |
dwUsage is RESOURCEUSAGE_CONTAINER | |
lpLocalName, lpRemoteName, and lpProvider, are NULL | |
lpComment is set to a descriptive text for the root of the network |