WlanDisconnect function (wlanapi.h)
The WlanDisconnect function disconnects an interface from its current network.
DWORD WlanDisconnect( [in] HANDLE hClientHandle, [in] const GUID *pInterfaceGuid, PVOID pReserved );
The client's session handle, obtained by a previous call to the WlanOpenHandle function.
The GUID of the interface to be disconnected.
Reserved for future use. Must be set to NULL.
If the function succeeds, the return value is ERROR_SUCCESS.
If the function fails, the return value may be one of the following return codes.
||hClientHandle is NULL or invalid, pInterfaceGuid is NULL, or pReserved is not NULL.|
||The handle hClientHandle was not found in the handle table.|
||Various error codes.|
||Failed to allocate memory for the query results.|
||The caller does not have sufficient permissions.|
When the connection was established using WlanConnect, a profile was specified by the strProfile member of the WLAN_CONNECTION_PARAMETERS structure pointed to by pConnectionParameters. If that profile was an all-user profile, the WlanDisconnect caller must have execute access on the profile. Otherwise, the WlanDisconnect call will fail with return value ERROR_ACCESS_DENIED. The permissions on an all-user profile are established when the profile is created or saved using WlanSetProfile or WlanSaveTemporaryProfile.
To perform a disconnection operation at the command line, use the netsh wlan disconnect command. For more information, see Netsh Commands for Wireless Local Area Network (wlan).
Windows XP with SP3 and Wireless LAN API for Windows XP with SP2: WlanDisconnect has the side effect of modifying the profile associated with the disconnected network. A network profile becomes an on-demand profile after a WlanDisconnect call. The Wireless Zero Configuration service will not connect automatically to a network with an on-demand profile when the network is in range. Do not call WlanDisconnect before calling WlanConnect unless you want to change a profile to an on-demand profile. When you call WlanConnect to establish a network connection, any existing network connection is dropped automatically.
|Minimum supported client||Windows Vista, Windows XP with SP3 [desktop apps only]|
|Minimum supported server||Windows Server 2008 [desktop apps only]|
|Header||wlanapi.h (include Wlanapi.h)|
|Redistributable||Wireless LAN API for Windows XP with SP2|