英文:
Why windows wifi API 'WlanEnumInterfaces' is failed with 'ERROR_INVALID_STATE'?
问题
以下是代码的中文翻译部分:
我正在尝试使用Windows API枚举WiFi网络,但我不知道为什么会出现错误代码ERROR_INVALID_STATE。以下是我的示例代码:
PWLAN_INTERFACE_INFO_LIST pIfList = NULL;
DWORD dwNegotiatedVersion;
HANDLE hClientHandle;
DWORD Res = WFDOpenHandle(WFD_API_VERSION, &dwNegotiatedVersion, &hClientHandle);
if (Res != ERROR_SUCCESS)
{
WFDCloseHandle(hClientHandle);
return;
}
Res = WlanEnumInterfaces(hClientHandle, NULL, &pIfList);
if (Res == ERROR_INVALID_STATE)
{
WlanCloseHandle(hClientHandle, NULL);
return;
}
else if (Res != ERROR_SUCCESS)
{
WlanCloseHandle(hClientHandle, NULL);
return;
}
我正在使用Windows 10,并使用Visual Studio 2015进行调试。
英文:
I am trying to enumerate the WiFi networks with windows API. But I don't know why it fails with the error code ERROR_INVALID_STATE . Below is my sample code
PWLAN_INTERFACE_INFO_LIST pIfList = NULL;
DWORD dwNegotiatedVersion;
HANDLE hClientHandle;
DWORD Res=WFDOpenHandle(WFD_API_VERSION, &dwNegotiatedVersion, &hClientHandle);
if (Res != ERROR_SUCCESS)
{
WFDCloseHandle(hClientHandle);
return;
}
Res = WlanEnumInterfaces(hClientHandle, NULL, &pIfList);
if (Res == ERROR_INVALID_STATE)
{
WlanCloseHandle(hClientHandle, NULL);
return;
}
else if (Res != ERROR_SUCCESS)
{
WlanCloseHandle(hClientHandle, NULL);
return;
}
I am using Windows 10.and debugging using visual studio 2015
答案1
得分: 2
WlanEnumInterfaces
中的句柄是从 WlanOpenHandle
获得的句柄,如文档所述。它不是来自 WFDOpenHandle
的 WFD 句柄。
英文:
The handle for WlanEnumInterfaces
is a handle from WlanOpenHandle
- as stated in the documentation. It is not a WFD handle from WFDOpenHandle
.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论