#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; } } };?
?