WlanHostedNetworkStopUsing function (wlanapi.h)

The WlanHostedNetworkStopUsing function stops the wireless Hosted Network.


DWORD WlanHostedNetworkStopUsing(
  [in]            HANDLE                      hClientHandle,
  [out, optional] PWLAN_HOSTED_NETWORK_REASON pFailReason,
                  PVOID                       pvReserved


[in] hClientHandle

The client's session handle, returned by a previous call to the WlanOpenHandle function.

[out, optional] pFailReason

An optional pointer to a value that receives the failure reason if the call to the WlanHostedNetworkStopUsing function fails. Possible values for the failure reason are from the WLAN_HOSTED_NETWORK_REASON enumeration type defined in the Wlanapi.h header file.


Reserved for future use. This parameter must be NULL.

Return value

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.

Return code Description
A handle is invalid. This error is returned if the handle specified in the hClientHandle parameter was not found in the handle table.
A parameter is incorrect. This error is returned if any of the following conditions occur:
  • hClientHandle is NULL.
  • pvReserved is not NULL.
The resource is not in the correct state to perform the requested operation. This can occur if the wireless Hosted Network was in the process of shutting down.
The service has not been started. This error is returned if the WLAN AutoConfig Service is not running.
Various RPC and other error codes. Use FormatMessage to obtain the message string for the returned error.


The WlanHostedNetworkStopUsing function is an extension to native wireless APIs added to support the wireless Hosted Network on Windows 7 and on Windows Server 2008 R2 with the Wireless LAN Service installed.

An application calls the WlanHostedNetworkStopUsing function to stop the Hosted Network. A application calls the WlanHostedNetworkStopUsing function to match earlier successful calls to the WlanHostedNetworkStartUsing function. The wireless Hosted Network will remain active until all applications have called the WlanHostedNetworkStopUsing function or the WlanHostedNetworkForceStop function is called to force a stop. When the wireless Hosted Network has stopped, the state switches to wlan_hosted_network_idle. This call could also fail if the Hosted Network state changed because of external events (for example, if the miniport driver for the wireless interface card becomes unavailable).

Any user can call this function to stop the Hosted Network. However, the ability to enable the wireless Hosted Network may be restricted by group policy in a domain.

On Windows 7 and later, the operating system installs a virtual device if a Hosted Network capable wireless adapter is present on the machine. This virtual device normally shows up in the “Network Connections Folder” as ‘Wireless Network Connection 2’ with a Device Name of ‘Microsoft Virtual WiFi Miniport adapter’ if the computer has a single wireless network adapter. This virtual device is used exclusively for performing software access point (SoftAP) connections and is not present in the list returned by the WlanEnumInterfaces function. The lifetime of this virtual device is tied to the physical wireless adapter. If the physical wireless adapter is disabled, this virtual device will be removed as well. This feature is also available on Windows Server 2008 R2 with the Wireless LAN Service installed.


Minimum supported client Windows 7 [desktop apps only]
Minimum supported server Windows Server 2008 R2 [desktop apps only]
Target Platform Windows
Header wlanapi.h (include Wlanapi.h)
Library Wlanapi.lib
DLL Wlanapi.dll

See also

About the Wireless Hosted Network

Using Wireless Hosted Network and Internet Connection Sharing