我正在编写一个仅限Windows的应用程序,需要连接到用户将提供其名称的各种WiFi网络。由于某种原因,WlanConnect(...)函数返回87,这意味着有一个无效参数,但我不确定哪个参数无效,或者为什么。
//iOS - Notification Framework (version 10 and above).
var content = new UNMutableNotificationContent();
content.Title = "test";
content.Subtitle = "Notification Subtitle";
content.Body = "test 02";
content.Badge = 1;
var trigger = UNTimeIntervalNotificationTrigger.CreateTrigger(5, false);
var requestID = "123";
var request = UNNotificationRequest.FromIdentifier(requestID, content, trigger);
UNUserNotificationCenter.Current.AddNotificationRequest(request, (err) => {
if (err != null)
{
// Do something with error...
}
});
我怎样才能确定这里有什么不妥之处?
编辑:
添加功能定义。
HANDLE wlanHandle;
unsigned long nv;
WlanOpenHandle(1, NULL, &nv, &wlanHandle);
DWORD dwResult = 0;
WLAN_CONNECTION_PARAMETERS cp;
memset(&cp, 0, sizeof(WLAN_CONNECTION_PARAMETERS));
cp.wlanConnectionMode = wlan_connection_mode_profile;
cp.strProfile = convertCharArrayToLPCWSTR(scannerName);
cp.dwFlags = 0;
cp.pDot11Ssid = NULL;
cp.pDesiredBssidList = 0;
cp.dot11BssType = dot11_BSS_type_independent;
PWLAN_INTERFACE_INFO_LIST pIfList = NULL;
PWLAN_INTERFACE_INFO pIfInfo = NULL;
// only use the first wifi interface
dwResult = WlanEnumInterfaces(wlanHandle, NULL, &pIfList);
if (dwResult == ERROR_SUCCESS)
{
pIfInfo = (WLAN_INTERFACE_INFO *)&pIfList->InterfaceInfo[0];
dwResult = WlanConnect(wlanHandle, &(pIfInfo->InterfaceGuid), &cp, NULL);
if (dwResult == ERROR_SUCCESS)
{
connected = true;
}
}