无线局域网连接问题

Wlan connection issue

我想使用 WlanConnect 函数连接到 wireless access point

代码:

HANDLE hClient;
PWLAN_INTERFACE_INFO_LIST pIfList;
PWLAN_INTERFACE_INFO pIfInfo;
PWLAN_AVAILABLE_NETWORK_LIST pBssList;

DWORD dwResult = 0;
WLAN_CONNECTION_PARAMETERS connectionParameters;
memset(&connectionParameters, 0, sizeof(WLAN_CONNECTION_PARAMETERS));
connectionParameters.wlanConnectionMode = wlan_connection_mode_profile;
connectionParameters.strProfile = pBssList->Network[apIndex].strProfileName;
connectionParameters.dwFlags = 0;
connectionParameters.pDot11Ssid = NULL;
connectionParameters.pDesiredBssidList = 0;
connectionParameters.dot11BssType = dot11_BSS_type_any;
dwResult = WlanConnect(hClient, &pIfInfo->InterfaceGuid, &connectionParameters, NULL);

if (dwResult == ERROR_SUCCESS) {
    qDebug() << "Connected!";
} else {
    qDebug() << dwResult;
}

当连接到open AP时,我得到87 error code,这意味着参数错误。任何想法什么参数可能是错误的?提前致谢。

我已经弄明白并解决了这个问题。问题是 WlanSetProfile 函数未在 WlanConnect 函数之前设置。