我如何可以打开一个无线适配器无线电,实际上是关闭? [英] How can I turn ON radio of a Wifi adapter that is actually OFF?

查看:392
本文介绍了我如何可以打开一个无线适配器无线电,实际上是关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用href="http://managedwifi.$c$cplex.com" rel="nofollow">管理无线让我的WiFi适配器的无线电波状态

事情是这样的:

  WlanClient wlanClient =新WlanClient()
VAR targetInterface = wlanClient.Interfaces.FirstOrDefault()
如果(targetInterface!= NULL)
{
    布尔radioIsOff = targetInterface .RadioState.PhyRadioState [0] == .dot11SoftwareRadioState Wlan.Dot11RadioState.Off;
    如果(radioIsOff)
    {
       // 去做
    }
}
 

解决方案

我只是说这对 WlanInterface 类管理无线API的:

  IntPtr的radioStatePtr =新的IntPtr(0L);
        尝试
        {
            Wlan.WlanPhyRadioState radioState =新Wlan.WlanPhyRadioState();
            radioState.dwPhyIndex = 0; // TODO:可以改变???
            radioState.dot11HardwareRadioState = Wlan.Dot11RadioState.On; //忽略其实,根据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,假);

            Wlan.ThrowIfError(
                Wlan.WlanSetInterface(
                            client.clientHandle,
                            info.interfaceGuid,
                            Wlan.WlanIntf​​Op code.RadioState,
                            (UINT)Marshal.SizeOf(typeof运算(Wlan.WlanPhyRadioState)),
                            radioStatePtr,
                            IntPtr.Zero));
        }
        最后
        {
            如果(radioStatePtr.ToInt64()!= 0)
                Marshal.FreeHGlobal(radioStatePtr);
        }
 

测试在Win 7。

I'm using Managed Wifi to get the radio state of my Wifi adapter. How can I turn the radio ON in case it is actually off ?

Something like this :

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
    }
}

解决方案

I just added this to the WlanInterface class of the Managed Wifi API :

        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);
        }

Tested on Win 7.

这篇关于我如何可以打开一个无线适配器无线电,实际上是关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆