WNetOpenEnum

This function starts an enumeration of network resources or existing connections.

At a Glance

Header file: Winnetwk.h
Windows CE versions: 2.0 and later

Syntax

DWORD WNetOpenEnum(DWORD dwScope, DWORD dwType,
DWORD dwUsage, LPNETRESOURCE lpNetResource,
LPHANDLE lphEnum);

Parameters

dwScope

[in] Specifies the scope of the enumeration. This parameter can be one of the following values:

Value Description
RESOURCE_CONNECTED All currently connected resources (the dwUsage parameter is ignored).
RESOURCE_GLOBALNET All resources on the network.
RESOURCE_REMEMBERED All remembered (persistent) connections (the dwUsage parameter is ignored). These connections may or may not currently be connected.

dwType

[in] Specifies the resource types to enumerate. This parameter can be a combination of the following values:

Value Description
RESOURCETYPE_ANY All resources (this value cannot be combined with RESOURCETYPE_DISK or RESOURCETYPE_PRINT).
RESOURCETYPE_DISK All disk resources.
RESOURCETYPE_PRINT All print resources.

If the Windows CE network client cannot distinguish between print and disk resources, it may enumerate all resources.

dwUsage

[in] Specifies the resource usage to be enumerated. This parameter can be a combination of the following values:

Value Description
0 All resources
RESOURCEUSAGE_CONNECTABLE All connectable resources
RESOURCEUSAGE_CONTAINER All container resources

This parameter is ignored if the dwScope parameter is not RESOURCE_GLOBALNET.

lpNetResource

[in] Long pointer to a NETRESOURCE structure specifying the container to enumerate.

If an application needs to enumerate all the network resources, set the lpNetResource parameter to the topmost container, or the root, of the network.

This structure can be filled in by the application or may have been returned by a call to the WNetEnumResource function. The NETRESOURCE structure must specify a container resource; that is, the RESOURCEUSAGE_CONTAINER value must be specified in the dwUsage member.

To enumerate all network resources, an application can begin the enumeration by calling WNetOpenEnum with lpNetResource pointing to a NETRESOURCE structure specifying the root of the network, then using the returned handle with WNetEnumResource to enumerate resources. If one of the resources in the NETRESOURCE array returned by the WNetEnumResource function is a container resource, WNetOpenEnum can be used to open the resource for further enumeration.

If the dwScope parameter is not RESOURCE_GLOBALNET, this parameter must be NULL.

lphEnum

[out] Long pointer to a variable filled with an enumeration handle that can be used in a subsequent call to WNetEnumResource.

Return Values

ERROR_SUCCESS indicates success. An error value indicates failure. To get extended error information, call GetLastError. Possible GetLastError error values are described in the following table.

Value Description
ERROR_NOT_CONTAINER The lpNetResource parameter does not point to a container.
ERROR_INVALID_PARAMETER Either the dwScope or dwType parameter is invalid, or there is a bad combination of parameters.
ERROR_NO_NETWORK No network is present.

The function returns error values for compatibility with Windows for Workgroups. For compatibility with the Win32 API, the function also sets the error value returned by GetLastError.

Remarks

The WNetOpenEnum function is used to begin enumeration of the resources in a single container. The following code examples show the hierarchical structure of a Microsoft Windows Network:

LanMan (container, in this case the provider) 
 ACCOUNTING (container, in this case the domain) 
 \\ACCTSPAY (container, in this case the server) 
 PAYFILES (disk) 
 LASERJET (print)