WNetOpenEnum (Compact 7)


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

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


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

Value Description


All currently connected resources (the dwUsage parameter is ignored).


All resources on the network.


All remembered (persistent) connections (the dwUsage parameter is ignored). These connections may or may not currently be connected.


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

Value Description


All resources (this value cannot be combined with RESOURCETYPE_DISK or RESOURCETYPE_PRINT).


All disk resources.


All print resources.

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


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

Value Description


All resources.


All connectable resources.


All container resources.

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


[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.


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

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


The lpNetResource parameter does not point to a container.


Either the dwScope or dwType parameter is invalid, or there is a bad combination of parameters.


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.

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