Adding a Network Connection

To make a connection to a network resource described by a NETRESOURCE structure, an application can call the WNetAddConnection2 function, as shown in the following example.

DWORD dwResult;

NETRESOURCE nr;

dwResult = WNetAddConnection2(&nr, // NETRESOURCE from enumeration

(LPSTR) NULL, // no password

(LPSTR) NULL, // logged-in user

CONNECT_UPDATE_PROFILE); // update profile with connect info

if (dwResult == ERROR_ALREADY_ASSIGNED)

{

TextOut(hdc, 10, 10, "Already connected to specified resource.", 40);

return FALSE;

}

else if (dwResult == ERROR_DEVICE_ALREADY_REMEMBERED)

{

TextOut(hdc, 10, 10,

"Attempted reassignment of remembered device.", 44);

return FALSE;

}

else if(dwResult != NO_ERROR)

{

// An application-defined error handler is demonstrated in the

// section titled "Retrieving Network Errors."

NetErrorHandler(hwnd, dwResult, (LPSTR)"WNetAddConnection2");

return FALSE;

}

TextOut(hdc, 10, 10, "Connected to specified resource.", 32);

The WNetAddConnection function is supported for compatibility with earlier versions of Windows for Workgroups. For new applications, use WNetAddConnection2 or WNetAddConnection3.

Software for developers
Delphi Components
.Net Components
Software for Android Developers
More information resources
MegaDetailed.Net
Unix Manual Pages
Delphi Examples
Databases for Amazon shops developers
Amazon Categories Database
Browse Nodes Database