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
);
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.