WNetConnectionDialog1A function (winnetwk.h)

The WNetConnectionDialog1 function brings up a general browsing dialog for connecting to network resources. The function requires a CONNECTDLGSTRUCT to establish the dialog box parameters.


DWORD WNetConnectionDialog1A(
  [in, out] LPCONNECTDLGSTRUCTA lpConnDlgStruct


[in, out] lpConnDlgStruct

Pointer to a CONNECTDLGSTRUCT structure. The structure establishes the browsing dialog parameters.

Return value

If the user cancels the dialog box, the function returns –1. If the function is successful, it returns NO_ERROR. Also, if the call is successful, the dwDevNum member of the CONNECTDLGSTRUCT structure contains the number of the connected device.

Typically this dialog returns an error only if the user cannot enter a dialog session. This is because errors that occur after a dialog session are reported to the user directly. If the function fails, the return value is a system error code, such as one of the following values.

Return code Description
Both the CONNDLG_RO_PATH and the CONNDLG_USE_MRU dialog box options are set. (Dialog box options are specified by the dwFlags member of the CONNECTDLGSTRUCT structure.)


Both the CONNDLG_PERSIST and the CONNDLG_NOT_PERSIST dialog box options are set.


The CONNDLG_RO_PATH dialog box option is set and the lpRemoteName member of the NETRESOURCE structure does not point to a remote network. (The CONNECTDLGSTRUCT structure points to a NETRESOURCE structure.)

The dwType member of the NETRESOURCE structure is not set to RESOURCETYPE_DISK.
The network provider is busy (possibly initializing). The caller should retry.
The network is unavailable.
There is insufficient memory to display the dialog box.
A network-specific error occurred. Call WNetGetLastError to obtain a description of the error.



The winnetwk.h header defines WNetConnectionDialog1 as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.


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