WlanConnect function
The WlanConnect function attempts to connect to a specific network.
Syntax
DWORD WINAPI WlanConnect( _In_ HANDLE hClientHandle, _In_ const GUID *pInterfaceGuid, _In_ const PWLAN_CONNECTION_PARAMETERS pConnectionParameters, _Reserved_ PVOID pReserved );
Parameters
- hClientHandle [in]
-
The client's session handle, returned by a previous call to the WlanOpenHandle function.
- pInterfaceGuid [in]
-
The GUID of the interface to use for the connection.
- pConnectionParameters [in]
-
Pointer to a WLAN_CONNECTION_PARAMETERS structure that specifies the connection type, mode, network profile, SSID that identifies the network, and other parameters.
Windows XP with SP3 and Wireless LAN API for Windows XP with SP2: There are some constraints on the WLAN_CONNECTION_PARAMETERS members. This means that structures that are valid for Windows Server 2008 and Windows Vista may not be valid for Windows XP with SP3 or Wireless LAN API for Windows XP with SP2. For a list of constraints, see WLAN_CONNECTION_PARAMETERS. - pReserved
-
Reserved for future use. Must be set to 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 |
|---|---|
|
One of the following conditions occurred:
|
|
The handle hClientHandle was not found in the handle table. |
|
Various error codes. |
|
The caller does not have sufficient permissions. |
Remarks
The WlanConnect function returns immediately. To be notified when a connection is established or when no further connections will be attempted, a client must register for notifications by calling WlanRegisterNotification.
The strProfile member of the WLAN_CONNECTION_PARAMETERS structure pointed to by pConnectionParameters specifies the profile to use for connection. If this profile is an all-user profile, the WlanConnect caller must have execute access on the profile. Otherwise, the WlanConnect 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 connection operation at the command line, use the netsh wlan connect 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: You can only use WlanConnect to connect to networks on the preferred network list. To add a network to the preferred network list, call WlanSetProfile.
Requirements
|
Minimum supported client | Windows Vista, Windows XP with SP3 [desktop apps only] |
|---|---|
|
Minimum supported server | Windows Server 2008 [desktop apps only] |
|
Redistributable | Wireless LAN API for Windows XP with SP2 |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
Send comments about this topic to Microsoft
Build date: 11/29/2012
