Platform SDK: Network Management

NetUseEnum

The NetUseEnum function lists all current connections between the local computer and resources on remote servers.

Win32-based applications can also use the WNetOpenEnum and the WNetEnumResource functions to enumerate network resources or connections.

Security Requirements

No special group membership is required to call the NetUseEnum function. This function cannot be executed on a remote server.

NET_API_STATUS NetUseEnum (
  LPWSTR UncServerName,  
  DWORD Level,        
  LPBYTE *BufPtr,
  DWORD PreferedMaximumSize,
  LPDWORD EntriesRead,
  LPDWORD TotalEntries,
  LPDWORD ResumeHandle
);

Parameters

UncServerName
[in] Reserved; must be NULL.
Level
[in] Specifies the information level of the data. This parameter can be one of the following values.
Value Meaning
0 Specifies a local device name and the share name of a remote resource. The BufPtr parameter points to an array of USE_INFO_0 structures.
1 Specifies information about the connection between a local device and a shared resource, including connection status and type. The BufPtr parameter points to an array of USE_INFO_1 structures.
2 Specifies information about the connection between a local device and a shared resource. Information includes the connection status, connection type, user name, and domain name. The BufPtr parameter points to an array of USE_INFO_2 structures.

BufPtr
[out] Pointer to the buffer that receives the information structures. The format of this data depends on the value of the Level parameter. This buffer is allocated by the system and must be freed using the NetApiBufferFree function. Note that you must free the buffer even if the function fails with ERROR_MORE_DATA.
PreferedMaximumSize
[in] Specifies the preferred maximum length of the data returned, in bytes. If you specify MAX_PREFERRED_LENGTH, the function allocates the amount of memory required for the data. If you specify another value in this parameter, it can restrict the number of bytes that the function returns. If the buffer size is insufficient to hold all entries, the function returns ERROR_MORE_DATA. For more information, see Network Management Function Buffers and Network Management Function Buffer Lengths.
EntriesRead
[out] Pointer to a DWORD value that receives the count of elements actually enumerated.
TotalEntries
[out] Pointer to a DWORD value that receives the total number of entries that could have been enumerated from the current resume position.
ResumeHandle
[in/out] Pointer to a DWORD value that contains a resume handle which is used to continue the search. The handle should be zero on the first call and left unchanged for subsequent calls. If ResumeHandle is NULL, then no resume handle is stored.

Return Values

If the function succeeds, the return value is NERR_Success.

If the function fails, the return value is a Win32 API error code. For a list of error codes, see Error Codes.

Remarks

To retrieve information about one network connection, you can call the NetUseGetInfo function.

Requirements

  Windows NT/2000: Requires Windows NT 3.1 or later.
  Windows 95/98: Unsupported.
  Header: Declared in Lmuse.h; include Lm.h.
  Library: Use Netapi32.lib.

See Also

Network Management Overview, Network Management Functions, Use Functions, USE_INFO_0, USE_INFO_1, USE_INFO_2, NetUseGetInfo, WNetEnumResource, WNetOpenEnum