Platform SDK: Windows Networking |
The WNetEnumResource function continues an enumeration of network resources that was started by a call to the WNetOpenEnum function.
DWORD WNetEnumResource( HANDLE hEnum, // handle to enumeration LPDWORD lpcCount, // entries to list LPVOID lpBuffer, // buffer LPDWORD lpBufferSize // buffer size );
If the function succeeds, on return the variable pointed to by this parameter contains the number of entries actually read.
The buffer is valid until the next call using the handle specified by the hEnum parameter. The order of NETRESOURCE structures in the array is not predictable.
If the function succeeds, the return value is one of the following values.
Value | Meaning |
---|---|
NO_ERROR | The enumeration succeeded, and the buffer contains the requested data. The calling application can continue to call WNetEnumResource to complete the enumeration. |
ERROR_NO_MORE_ITEMS | There are no more entries. The buffer contents are undefined. |
If the function fails, the return value can be one of the following error codes.
Value | Meaning |
---|---|
ERROR_MORE_DATA | More entries are available with subsequent calls. |
ERROR_INVALID_HANDLE | The handle specified by the hEnum parameter is not valid. |
ERROR_NO_NETWORK | The network is unavailable. (This condition is tested before hEnum is tested for validity.) |
ERROR_EXTENDED_ERROR | A network-specific error occurred. To obtain a description of the error, call the WNetGetLastError function. |
The WNetEnumResource function does not enumerate users connected to a share; you can call the NetConnectionEnum function to accomplish this task. To enumerate hidden shares, call the NetShareEnum function.
An application cannot set the lpBuffer parameter to NULL and retrieve the required buffer size from the lpBufferSize parameter. Instead, the application should allocate a buffer of a reasonable size — 16 kilobytes (K) is typical — and use the value of lpBufferSize for error detection.
For a code sample that illustrates an application-defined function that enumerates all the resources on a network, see Enumerating Network Resources.
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Winnetwk.h.
Library: Use Mpr.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.
Windows Networking (WNet) Overview, Windows Networking Functions, NETRESOURCE, WNetCloseEnum, WNetOpenEnum