WNet Functions

Windows Networking functions provide information and utilities for managing network resources. The Windows Networking functions can be grouped as follows:

Connection Functions

Call the following WNet connection functions to connect a local device to a network resource, and to cancel network connections.

Function Description
MultinetGetConnectionPerformance Returns information about the expected performance of a connection to a network resource.
WNetAddConnection Connects a local device to a network resource. (Provided for compatibility with 16-bit versions of Windows.)
WNetAddConnection2 Connects a local device to a network resource.
WNetAddConnection3 Connects a local device to a network resource. This function includes one more parameter than the WNetAddConnection2 function, a handle to a window that the network provider can use as an owner window for dialog boxes.
WNetCancelConnection Cancels a network connection. (Provided for compatibility with 16-bit versions of Windows.)
WNetCancelConnection2 Cancels a network connection, providing the ability to update the user profile with information about persistent connections.
WNetConnectionDialog Starts a general browsing dialog box for connecting to network resources.
WNetConnectionDialog1 Starts a general browsing dialog box for connecting to network resources, using a CONNECTDLGSTRUCT structure.
WNetDisconnectDialog Starts a general browsing dialog box for disconnecting from network resources.
WNetDisconnectDialog1 Starts a general browsing dialog box for disconnecting from network resources, using a DISCDLGSTRUCT structure.
WNetGetConnection Retrieves the name of the network resource associated with a local device.
WNetGetUniversalName When given a drive-based path for a network resource, returns a more universal form of the name.
WNetRestoreConnectionW Restores the connection to a network resource, prompting the user, if necessary, for a name and password.
WNetUseConnection Connects a local device to a network resource; automatically selects an unused local device to redirect to the network resource.

 

Note

The WNetAddConnection and WNetCancelConnection functions are supported for compatibility with Windows for Workgroups. However, new applications should use WNetAddConnection2 or WNetAddConnection3, and WNetCancelConnection2.

 

Enumeration Functions

Call the following WNet functions to enumerate network resources.

Function Description
WNetCloseEnum Ends a network resource enumeration.
WNetEnumResource Continues an enumeration of network resources started by the WNetOpenEnum function.
WNetOpenEnum Starts an enumeration of network resources.

 

Information Functions

Call the following WNet informational and utility functions to retrieve network provider and other information.

Function Description
WNetGetLastError Returns the most recent error code set by a WNet function, the one reported by a network provider.
WNetGetNetworkInformation Returns extended information about a specific network provider.
WNetGetProviderName Returns the provider name for a specific type of network.
WNetGetResourceInformation Returns the network provider that owns a resource, and obtains information about the resource type.
WNetGetResourceParent Returns the parent of a network resource.

 

User Functions

Call the following WNet function to retrieve the name of the user associated with a local device.

Function Description
WNetGetUser Returns the current default user name, or the user name that established the connection.

 

Many of the WNet functions use a NETRESOURCE structure to store information about a network resource.