Platform SDK: Windows Networking |
The WNetCancelConnection function cancels an existing network connection.
The WNetCancelConnection function is provided for compatibility with 16-bit versions of Windows. Win32-based applications should call the WNetCancelConnection2 function.
DWORD WNetCancelConnection( LPCTSTR lpName, // resource name BOOL fForce // unconditional disconnect option );
When this parameter specifies a redirected local device, the function cancels only the specified device redirection. If the parameter specifies a remote network resource, only the connections to remote networks without devices are canceled.
If the function succeeds, the return value is NO_ERROR.
If the function fails, the return value can be one of the following error codes.
Value | Meaning |
---|---|
ERROR_BAD_PROFILE | The user profile is in an incorrect format. |
ERROR_CANNOT_OPEN_PROFILE | The system is unable to open the user profile to process persistent connections. |
ERROR_DEVICE_IN_USE | The device is in use by an active process and cannot be disconnected. |
ERROR_EXTENDED_ERROR | A network-specific error occurred. To obtain a description of the error, call the WNetGetLastError function. |
ERROR_NOT_CONNECTED | The name specified by the lpName parameter is not a redirected device, or the system is not currently connected to the device specified by the parameter. |
ERROR_OPEN_FILES | There are open files, and the fForce parameter is FALSE. |
Windows NT/2000: Requires Windows NT 3.1 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in Winnetwk.h.
Library: Use Mpr.lib.
Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.
Windows Networking (WNet) Overview, Windows Networking Functions, WNetAddConnection, WNetAddConnection2, WNetCancelConnection2, WNetGetConnection