This function breaks an existing network connection.
At a Glance
Header file: | Winnetwk.h |
Windows CE versions: | 2.0 and later |
Syntax
DWORD WNetCancelConnection2(LPTSTR lpName, DWORD dwFlags, BOOL fForce);
Parameters
lpName
[in] Long pointer to a null-terminated string that specifies the name of either the local name or the remote network resource to disconnect from. If this parameter specifies a local name, only the specified redirection is broken; otherwise, all connections to the remote network resource are broken.
dwFlags
[in] Specifies a bitmask for the connection type. The following values are defined:
Value | Description |
0 | No stored information about the connection is updated. |
CONNECT_UPDATE_PROFILE | The system is updated with the information that this is no longer a persistent connection. Disconnecting resources using remote names has no effect on persistent connections. |
fForce
[in] Boolean that specifies whether the disconnection should occur even if there are open files or jobs on the connection. If this parameter is FALSE, the function fails if there are open files or jobs.
Return Values
ERROR_SUCCESS indicates success. An error value indicates failure. To get extended error information, call GetLastError. Possible GetLastError values are described in the following table.
Value | Description |
ERROR_DEVICE_IN_USE | The device is in use by an active process and cannot be disconnected. |
ERROR_NOT_CONNECTED | The name specified by the lpName parameter is not a local or remote network resource, 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. |
Remarks
Connections are not automatically restored when the system is started.