WNetConnectionDialog function (winnetwk.h)

The WNetConnectionDialog function starts a general browsing dialog box for connecting to network resources. The function requires a handle to the owner window for the dialog box.


DWORD WNetConnectionDialog(
  [in] HWND  hwnd,
  [in] DWORD dwType


[in] hwnd

Handle to the owner window for the dialog box.

[in] dwType

Resource type to allow connections to. This parameter can be the following value.

Value Meaning
Connections to disk resources.

Return value

If the function succeeds, the return value is NO_ERROR. If the user cancels the dialog box, the function returns –1.

If the function fails, the return value is a system error code, such as one of the following values.

Return code Description
A network-specific error occurred. To obtain a description of the error, call the WNetGetLastError function.
The specified password is invalid.
The network is unavailable.
There is insufficient memory to start the dialog box.


If the user clicks OK in the dialog box, the requested network connection will have been made when the WNetConnectionDialog function returns.

If the function attempts to make a connection and the network provider returns the message ERROR_INVALID_PASSWORD, the system prompts the user to enter a password. The system uses the new password in another attempt to make the connection.


Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header winnetwk.h
Library Mpr.lib
DLL Mpr.dll

See also




Windows Networking (WNet) Overview

Windows Networking Functions