Freigeben über


WlanConnect (Compact 2013)

3/26/2014

This 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] Handle to the session on the client. To obtain a handle, call WlanOpenHandle.
  • 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.
  • pReserved
    Reserved; set to NULL.

Return Values

Value

Description

ERROR_SUCCESS

The function succeeds.

ERROR_INVALID_PARAMETER

One of the following conditions occurred:

  • hClientHandle is NULL or invalid.
  • pInterfaceGuid is NULL.
  • pConnectionParameters is NULL.
  • The dwFlags member of the structure pointed to by pConnectionParameters is not set to a value designated on the WLAN_CONNECTION_PARAMETERS page.
  • The wlanConnectionMode member of the structure pointed to by pConnectionParameters is set to wlan_connection_mode_discovery_secure or wlan_connection_mode_discovery_unsecure, and the pDot11Ssid member of the same structure is NULL.
  • The wlanConnectionMode member of the structure pointed to by pConnectionParameters is set to wlan_connection_mode_discovery_secure or wlan_connection_mode_discovery_unsecure, and the dot11BssType member of the same structure is set to dot11_BSS_type_any.
  • The wlanConnectionMode member of the structure pointed to by pConnectionParameters is set to wlan_connection_mode_profile, and the strProfile member of the same structure is NULL or the length of the profile exceeds WLAN_MAX_NAME_LENGTH.
  • The wlanConnectionMode member of the structure pointed to by pConnectionParameters is set to wlan_connection_mode_profile, and the strProfile member of the same structure is NULL or the length of the profile is zero.
  • The wlanConnectionMode member of the structure pointed to by pConnectionParameters is set to wlan_connection_mode_invalid.
  • The dot11BssType member of the structure pointed to by pConnectionParameters is set to dot11_BSS_type_infrastructure, and the dwFlags member of the same structure is set to WLAN_CONNECTION_ADHOC_JOIN_ONLY.
  • The dot11BssType member of the structure pointed to by pConnectionParameters is set to dot11_BSS_type_independent, and the dwFlags member of the same structure is set to WLAN_CONNECTION_HIDDEN_NETWORK.
  • The dwFlags member of the structure pointed to by pConnectionParameters is set to WLAN_CONNECTION_IGNORE_PRIVACY_BIT, and either the wlanConnectionMode member of the same structure is not set to wlan_connection_mode_temporary_profile or the dot11BssType member of the same structure is set to dot11_BSS_type_independent.

ERROR_INVALID_HANDLE

The handle hClientHandle was not found in the handle table.

RPC_STATUS

Can be any Remote Procedure Call (RPC) error code. The RPC call may be unsuccessful due to Wlan RPC server issues, such as when the RPC server is not started. Refer to RPC for more information.

ERROR_ACCESS_DENIED

One of the following occurred:

  • The caller does not have sufficient permissions.
  • You included Connection Manager in your OS.
  • The strProfile member of the WLAN_CONNECTION_PARAMETERS structure pointed to by pConnectionParameters determines the profile to use for connection.

Remarks

If you include Connection Manager in your OS design:

The WlanConnect function returns immediately. If you want be notified when it establishes a connection, or when it will no longer attempt additional connections, you can register for notifications by calling WlanRegisterNotification.

See Also

Reference

Native Wi-Fi Functions
WlanOpenHandle
WlanRegisterNotification
WLAN_CONNECTION_PARAMETERS
WlanDisconnect
Native Wi-Fi Reference