Windows Mobile 中开关WIFI 的“通用”代码- samwong.cn - JavaEye技术网站
#pragma once
#include "UniBase.h"
#include "Reg.h"
#include <PM.h>

class CWiFiHelper
{
private:
    TCHAR m_tzDevice[MAX_NAME];

public:
    CWiFiHelper()
    {
        TCHAR tzKey[MAX_PATH];
        CReg reg(HKEY_LOCAL_MACHINE, TEXT("Comm"));
        for (UINT i = 0; reg.EnumKey(i, tzKey) == S_OK; i++)
        {
            if (tzKey[UStrLen(tzKey) - 1] == '1')
            {
                CReg dev(reg, tzKey);
                TCHAR tzDisplayName[MAX_PATH];
                if (dev.GetStr(TEXT("DisplayName"), tzDisplayName))
                {
                    if (UStrStrI(tzDisplayName, TEXT("WiFi")) ||
                        UStrStrI(tzDisplayName, TEXT("Wi-Fi")) ||
                        UStrStrI(tzDisplayName, TEXT("Wireless")) ||
                        UStrStr(tzDisplayName, TEXT("802.11")))
                    {
                        UStrPrint(m_tzDevice, PMCLASS_NDIS_MINIPORT TEXT("\\%s"), tzKey);
                        //MessageBox(NULL, m_tzDevice, STR_AppName, MB_ICONINFORMATION);
                        return;
                    }
                }
            }
        }
        m_tzDevice[0] = 0;
    }

    BOOL IsEnabled()
    {
        CEDEVICE_POWER_STATE s = D4;
        if (m_tzDevice [0])
        {
            GetDevicePower(m_tzDevice, POWER_NAME, &s);
        }
        return s == D0;
    }

    HRESULT Enable(BOOL bEnable = TRUE)
    {
        if (m_tzDevice [0])
        {
            return SetDevicePower(m_tzDevice, POWER_NAME, bEnable ? D0 : D4);
        }
        else
        {
            return ERROR_DEVICE_NOT_AVAILABLE;
        }
    }
};
?

?

郑重声明:资讯 【Windows Mobile 中开关WIFI 的“通用”代码- samwong.cn - JavaEye技术网站】由 发布,版权归原作者及其所在单位,其原创性以及文中陈述文字和内容未经(企业库qiyeku.com)证实,请读者仅作参考,并请自行核实相关内容。若本文有侵犯到您的版权, 请你提供相关证明及申请并与我们联系(qiyeku # qq.com)或【在线投诉】,我们审核后将会尽快处理。
—— 相关资讯 ——