NPOpenEnum function (npapi.h)

Opens an enumeration of network resources or existing connections. The NPOpenEnum function must be called to obtain a valid handle for an enumeration.


  DWORD          dwScope,
  DWORD          dwType,
  DWORD          dwUsage,
  LPHANDLE       lphEnum



Determines the scope of the enumeration. This can be one of the following.

Value Meaning
All currently connected resources.
All resources on the network.
The resources associated with the user's current and default network context (used for a "Network Neighborhood" view). The interpretation of this is left to the provider.


Specifies the type of resources of interest. This is a bitmask, which may be any combination of the following flags.

Value Meaning
All disk resources.
All print resources.
Specifies that the function should fail if the caller is not authenticated (even if the network permits enumeration without authentication).

If dwType is 0, or is just RESOURCEUSAGE_ATTACHED, all types of resources are returned. If a provider does not have the capability to distinguish between print and disk resources at the same level, it may return all resources.


Specifies the usage of resources of interested. This is a bitmask, which may be any combination of the following flags.

Value Meaning
All connectable resources
All container resources

The bitmask may be zero to match all of the flags. This parameter may be ignored if dwScope is not set to RESOURCE_GLOBALNET.


Pointer to the container to perform the enumeration. The NETRESOURCE could have been obtained through a previous NPEnumResource call, or constructed by the caller, or it can be NULL. If it is NULL or if the lpRemoteName field of the NETRESOURCE is NULL, the provider should enumerate the top level of its network. Note that this means a provider cannot use an lpRemoteName of NULL to represent any network resource. A caller 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. Note that if dwScope is RESOURCE_CONNECTED or RESOURCE_CONTEXT, this parameter will be NULL.


Pointer to a handle that can be used by the NPEnumResource function. When you have finished using the handle, release the handle by calling the NPCloseEnum function.

Return value

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

Return code Description
The provider does not support the type of enumeration being requested, or the specific network resource cannot be browsed.
lpNetResource does not point to a container.
Invalid dwScope, dwUsage, or dwType or bad combination of parameters is specified.
The network is not present.


Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header npapi.h