This SPI is used to open an enumeration of network resources or existing connections. It must be called to obtain a valid handle for enumeration.
DWORD NPOpenEnum ( DWORD dwScope, DWORD dwType, DWORD dwUsage, LPNETRESOURCE lpNetResource, LPHANDLE lphEnum );
dwScope
Determines the scope of the enumeration. This can be one of the following:
RESOURCE_CONNECTED | All currently connected resources. |
RESOURCE_GLOBALNET | All resources on the network. |
RESOURCE_CONTEXT | The resources associated with the user's current and default network context (used for a "My Network" view). |
dwType
Used to specify the type of resources and level of detail of interest. This is a bit mask which may be any combination of the following:
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. If RESOURCETYPE_ANY is set, then the MPR also sets RESOURCETYPE_DISK and RESOURCETYPE_PRINT, so that if the NP enumerates only for printers and disks, then it need only test for RESOURCETYPE_DISK, and RESOURCETYPE_PRINT. It need not explicitly test for RESOURCETYPE_ANY. |
dwUsage
Used to specify the usage of resources of interest. This is a bit mask which may be any combination of the following:
RESOURCEUSAGE_CONNECTABLE | All connectable resources. |
RESOURCEUSAGE_CONTAINER | All container resources. |
RESOURCEUSAGE_ALL | All resources. |
lpNetResource
This specifies the container to perform the enumeration. The NETRESOURCE could have been obtained via a previous NPEnumResource, or constructed by the caller. If the lpRemoteName field of the NETRESOURCE is NULL, the NP should enumerate the top level of its network. A user would normally start off by calling NPOpenEnum with this parameter set to NULL, and then use the returned results for further enumeration. If the calling program knows exactly the provider and remote path to enumerate from, it may build its own NETRESOURCE structure to pass in, filling in the lpProvider and lpRemoteName fields. If dwScope is RESOURCE_CONNECTED lpNetResource is NULL.
lphEnum
If the function call is successful, this will contain a handle that can then be used for enumeration.
WN_NOT_SUPPORTED | The provider does not support the type of enumeration being requested, or the specific network resource cannot be browsed. |
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_NO_NETWORK | The network is not present. |
WN_NOT_AUTHENTICATED | Authentication needs to occur before the network resource can be enumerated. |
WN_NOT_LOGGED_ON | Logon needs to occur before the network resource can be enumerated. |
WN_ACCESS_DENIED | The user is authenticated to the network where the enumeration is being attempted, but does not have sufficient permissions (access rights). |