如何在.NET CF C# 3.5中连接到wifi网络

发布于 2024-08-23 03:43:34 字数 824 浏览 4 评论 0原文

这是我想在 .NET CF 3.5(C#) 应用程序中执行的操作

1) 检查无线适配器是否正在工作/活动 2) 添加首选网络以及可用的 SSID、密码和其他详细信息 3)建立与首选网络的连接

我尝试使用 OpenNetCF.Net.NetworkInformation 类,但运气不好!我无法检测到无线网络。所有网络(包括 wifi 和蓝牙)均显示为以太网。

foreach (var networkInterface in NetworkInterface.GetAllNetworkInterfaces())
{
    if (networkInterface is WirelessNetworkInterface)
        MessageBox.Show("Found a WirelessNetworkInterface");
    else if (networkInterface is WirelessZeroConfigNetworkInterface)
        MessageBox.Show("Found a WirelessZeroConfigNetworkInterface");
    else
        MessageBox.Show("Ethernet??");
}

我面临的问题在这里讨论 http://community.opennetcf.com/forums /t/11099.aspx。但没有解决办法。

是否有任何 .NET CF API 允许我与 Wifi 交互?

Here is what i wanted to do in a .NET CF 3.5(C#) application

1) Check if the wireless adapter is working/active
2) Add a preferred network with the available SSID, password and other details
3) Establish connection to the preferred network

I tried using OpenNetCF.Net.NetworkInformation class, but tough luck! I'm not able to detect Wireless networks. All the networks includnig wifi and bluetooth are shown as Ethernet.

foreach (var networkInterface in NetworkInterface.GetAllNetworkInterfaces())
{
    if (networkInterface is WirelessNetworkInterface)
        MessageBox.Show("Found a WirelessNetworkInterface");
    else if (networkInterface is WirelessZeroConfigNetworkInterface)
        MessageBox.Show("Found a WirelessZeroConfigNetworkInterface");
    else
        MessageBox.Show("Ethernet??");
}

The problem I'm facing is discussed here http://community.opennetcf.com/forums/t/11099.aspx. But there are no solutions.

Are there any .NET CF APIs that allow me to interact with Wifi?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不爱素颜 2024-08-30 03:43:34

你误会了。顾名思义,它列出了所有网络接口。蓝牙和 Wifi(甚至 RNDIS USB 连接)都是网络接口,因此将被枚举。基本上,这只是要求 NDIS 告诉我们它所知道的所有接口。

当它迭代时,它做了两件事。首先,它询问 WZC 是否了解该接口(即该接口的驱动程序是否已向 WZC 注册)。如果是,那么我们就知道它是符合 WZC 的无线设备,并且我们会获取它的更多信息并返回 WirelessZeroConfig 接口。

然后我们询问 NDIS 是报告自身为无线的设备的驱动程序。如果是,我们将获取无线的 NDIS 信息并返回无线接口。

其他一切都变成了通用的网络接口。

那么无线设备如何显示为通用网络接口呢?简单的。它的驱动程序没有在 WZC 注册,也没有通过 NDIS 报告它是无线的。我们的代码无法检测驱动程序未报告的内容。这实际上对于旧的 Cisco 卡来说有点常见,它使用 Cico 专有的无线接口。它们实际上是无线设备,但由于软件没有告诉我们它是无线设备,并且我们没有查询任何专有 API,因此我们所能做的就是返回适配器的通用 NDIS 信息。

如果您有这样的设备,唯一的办法就是与适配器 OEM 联系,看看他们是否有您可以使用的 API。

You're misunderstanding. It is listing, as the name implies, all network interfaces. Bluetooth and Wifi (and even RNDIS USB connections) are all network interfaces and therefore will be enumerated. Basically, under the hood this is just asking NDIS to tell us all of the interfaces it knows about.

While it is iterating, it does two things. First, it asks WZC if it knows about the interface (i.e. if the interface's driver registered with WZC). If it does, then we know it's a WZC-compliant wireless dvice and we get some more info for it and return a WirelessZeroConfig interface.

We then ask NDIS is the driver for the device reported itself as wireless. If it did, we then get the NDIS info for wireless and return a Wireless interface.

Everything else becomes a generic NetworkInterface.

So how could a wireless device show up as a generic NetworkInterface? Simple. The driver for it didn't register with WZC and also isn't reporting that it's wireless through NDIS. Our code can't detect what the driver doesn't report. This is actually somewhat common with older Cisco cards, which uses a Cico-proprietary interface for the wireless stuff. They are physically a wireless device, but since the software doesn't tell us that it is, and since we're not querying any proprietary APIs, all we can do is return the generic NDIS info for the adapter.

If you have such a device, the only recourse is to talk with the adapter OEM and see if they have an API for it that you can use.

吃→可爱长大的 2024-08-30 03:43:34

您可以使用 System.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType = NetworkInterfaceType.Wireless80211 来检测适配器是否是 WiFi 适配器。

You can use System.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType = NetworkInterfaceType.Wireless80211 to detect if the adapter is a WiFi apdater.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文