|
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.
Related Links
Software for Delphi and C++ Builder developers
Software for Visual Studio .NET developers
Software for Visual Basic 6 developers
Delphi Tips&Tricks
MegaDetailed.NET
More Online Helps
Win32 Multimedia Programmer's Reference (mmedia.hlp)
OLE Programmer's Reference (ole.hlp)
Microsoft Windows Pen API Programmer's Reference (penapi.hlp)
Microsoft Windows Sockets 2 Reference (sock2.hlp)
Microsoft Windows Telephony API (TAPI) Programmer's Reference (tapi.hlp)
Unix Manual Pages
|