Using the Connections Dialog Box

The WNetConnectionDialog function creates a dialog box that allows the user to browse and connect to network resources. You can also call the WNetConnectionDialog1 function to create a connections dialog box. WNetConnectionDialog1 requires a CONNECTDLGSTRUCT structure.

The WNetDisconnectDialog function creates a dialog box that allows the user to disconnect from network resources.

The following code sample demonstrates how to call the WNetConnectionDialog function to create a dialog box that displays disk resources. If the call fails, the sample calls an application-defined error handler.

DWORD dwResult; 
//
// Call the WNetConnectionDialog function.
//
dwResult = WNetConnectionDialog(hwnd, RESOURCETYPE_DISK);
//
// Call an application-defined error handler 
//  to process errors.
//
if(dwResult != NO_ERROR) 
{
    NetErrorHandler(hwnd, dwResult, (LPSTR)"WNetConnectionDialog"); 
    return FALSE; 
}

For more information about using an application-defined error handler, see Retrieving Network Errors.