zoukankan      html  css  js  c++  java
  • 也谈Windows Mobile中打开/关闭WIFI

    看到Yonsm兄写的“Windows Mobile 中开关 WIFI 的“通用”代码”一文。
    原文地址:http://www.yonsm.net/read.php?412

    在我机器(586W 6.1)测试无效,研究后发现Yonsm兄的算法并不通用,至少在我机器上无效。
    其实问题在于获取WIFI适配器的名称上。

    搜索了遍注册表,终于找到了解决办法。
    HKEY_LOCAL_MACHINE / System / CurrentControlSet / Control / POWER /
    State / {98C5250D-C29A-4985-AE5F-AFE5367E5006}\<DEVICE_NAME>

    其中<DEVICE_NAME>就是适配器的名称。
    注:{98C5250D-C29A-4985-AE5F-AFE5367E5006}\<DEVICE_NAME>是键的名称,不是子父路径的关系。

    将这个键的名称直接传给SetDevicePower的pvDevice参数即可。

    附:C#实现代码!

    string[] sNames = null;
                RegistryKey keyWlan 
    = null;
                
    try
                
    {
                    keyWlan 
    = Registry.LocalMachine.OpenSubKey(@"System\CurrentControlSet\Control\Power\State");
                    sNames 
    = keyWlan.GetValueNames();
                }

                
    catch { }
                
    finally
                
    {
                    
    if (keyWlan != null) keyWlan.Close();
                }


                
    foreach (string wl in sNames)
                
    {
                    
    if (wl.StartsWith("{98C5250D-C29A-4985-AE5F-AFE5367E5006}\\"))
                    
    {
                        
    //POWER_NAME = 0x00000001
                        SetDevicePower(wl0x00000001, open ? DevicePowerState.D0 : DevicePowerState.D4);
                        
    break;
                    }

                }
  • 相关阅读:
    EMV内核使用中的常见问题
    SM2国密证书合法性验证
    WP8.1中C++的winodws运行时组件位移操作的差异
    [源码]Literacy 快速反射读写对象属性,字段
    Vue 单文件元件 — vTabs
    vue-router路径计算问题
    前端跨域新方案尝试
    Vue 单文件原件 — vCheckBox
    JavaScript 功能类 Url.js
    Vue 学习笔记 — 组件初始化
  • 原文地址:https://www.cnblogs.com/mondol/p/1331421.html
Copyright © 2011-2022 走看看