NPEnumResource

NPEnumResource performs an enumeration based upon the handle returned by NPOpenEnum. On this call the NP fills the buffer with the requested number of entries (or the maximum that can fit). The returned NETRESOURCE structures must be located contiguously at the head of the buffer passed in (for example, an array of such structures), and the pointers in these structures must point to locations within the buffer. As such, data referenced by these pointers will be located at the end of the buffer, after the array of structures. It is the NP's responsibility to package this information correctly. Note that when returning an enumeration for dwScope set to RESOURCE_CONTEXT, all siblings must be returned together (contiguously, but may span buffers) with the RESOURCEUSAGE_SIBLING bit set in the dwUsage field for every sibling except the first.


DWORD NPEnumResource (
  HANDLE hEnum,
  LPDWORD lpcCount,
  LPVOID lpBuffer,
  DWORD cbBuffer,
  LPDWORD lpcbFree
  );

hEnum

This must be a handle obtained from NPOpenEnum call.

lpcCount

Specifies the number of entries requested. It may be 0xFFFFFFFF to request as many as possible. On successful call, this location will receive the number of entries actually read.

lpBuffer

A pointer to the buffer to receive the enumeration result, which are returned as an array of NETRESOURCE entries. The buffer is valid until the next call using hEnum.

cbBuffer

This specifies the size in bytes of the buffer passed to the function call.

lpcbFree

A pointer to a variable that the NP should set to the number of bytes remaining unused in the buffer. These bytes are the unused bytes immediately after the array of NETRESOURCE structures, and before the variable-length strings pointed to by those NETRESOURCE structures. When enumerating from multiple networks in turn, the MPR will pass the entire buffer to the first NP, then pass just the unused space to the next NP, and so on. If the NP cannot fit a single entry in the buffer, then the NP should set this variable to the number of bytes required to contain the next entry that it will return (including all variable-length strings, such as the provider name), and return a status of WN_MORE_DATA.

WN_NO_MORE_ENTRIES

No more entries found. The enumeration completed successfully (the contents of the return buffer is undefined). Other error codes include:

WN_MORE_DATA

The buffer is too small even for one entry. lpcbFree gives the size of buffer required for the next entry.

WN_BAD_HANDLE

hEnum is not a valid handle.

WN_NO_NETWORK

The network is not present. This condition is checked for before hEnum is tested for validity.


The lpNetResource provided to NPOpenEnum is guaranteed by the system to not be NULL. The NP sets lpProvider to point to the name of the NP (the name returned from calling NPSGetProviderName) for all enumerations.

When returning remote names, the NP should provide the complete remote name (as opposed to the shorter name displayed in the Explorer, which is generated using NPFormatNetworkName). For example, an entry describing a share would be returned as \\server\SHARE, which is a format suitable for passing to WNetAddConnection.