Canceling a Network Connection

To cancel a connection to a network resource, an application can call the WNetCancelConnection2 function, as shown in the following example.

DWORD dwResult;

dwResult = WNetCancelConnection2("z:",

CONNECT_UPDATE_PROFILE, // remove connection from profile

FALSE); //fail if open files or jobs

if (dwResult == ERROR_NOT_CONNECTED)

{

TextOut(hdc, 10, 10, "Drive z: not connected.", 23);

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)"WNetCancelConnection2");

return FALSE;

}

TextOut(hdc, 10, 10, "Connection closed for z:.", 25);

The WNetCancelConnection function is supported for compatibility with earlier versions of Windows for Workgroups. For new applications, use WNetCancelConnection2.

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