gpt4 book ai didi

c# - 如何打开实际上关闭的 Wifi 适配器的 radio ?

转载 作者:行者123 更新时间:2023-11-30 22:11:54 39 4
gpt4 key购买 nike

我正在使用 Managed Wifi获取我的 Wifi 适配器的 radio 状态。如果 radio 实际上已关闭,我该如何打开 radio ?

像这样:

WlanClient wlanClient = new WlanClient()
var targetInterface = wlanClient.Interfaces.FirstOrDefault()
if (targetInterface != null)
{
bool radioIsOff = targetInterface .RadioState.PhyRadioState[0].dot11SoftwareRadioState == Wlan.Dot11RadioState.Off;
if (radioIsOff)
{
// TODO
}
}

最佳答案

我刚刚将其添加到 Managed Wifi API 的 WlanInterface 类中:

        IntPtr radioStatePtr = new IntPtr(0L);
try
{
Wlan.WlanPhyRadioState radioState = new Wlan.WlanPhyRadioState();
radioState.dwPhyIndex = 0; // TODO : can change ???
radioState.dot11HardwareRadioState = Wlan.Dot11RadioState.On; // ignored in fact, according to http://msdn.microsoft.com/en-us/library/windows/desktop/ms706791(v=vs.85).aspx
radioState.dot11SoftwareRadioState = Wlan.Dot11RadioState.On;

radioStatePtr = Marshal.AllocHGlobal(Marshal.SizeOf(radioState));
Marshal.StructureToPtr(radioState, radioStatePtr, false);

Wlan.ThrowIfError(
Wlan.WlanSetInterface(
client.clientHandle,
info.interfaceGuid,
Wlan.WlanIntfOpcode.RadioState,
(uint)Marshal.SizeOf(typeof(Wlan.WlanPhyRadioState)),
radioStatePtr,
IntPtr.Zero));
}
finally
{
if (radioStatePtr.ToInt64() != 0)
Marshal.FreeHGlobal(radioStatePtr);
}

在 Win 7 上测试。

关于c# - 如何打开实际上关闭的 Wifi 适配器的 radio ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19985628/

39 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com