怎么获取手机信号强度?
RT
手机信号强度
或者干脆就是获取是否有信号……
[解决办法]
[HKEY_LOCAL_MACHINE\System\State\Phone\Signal Strength]
C#的话直接Microsoft.WindowsMobile.Status.SystemState.PhoneSignalStrength就可以找到,可以参考SDK中的例子:C:\Program Files\Windows Mobile 6 SDK\Samples\PocketPC\CS\StateAndNotificationBrokerViewer
[解决办法]
这是我写的获取手机信号代码类(C#)的,给你参考一下
/// <summary> /// 获取电池电量和信号类 /// </summary> public static class Battery_signal { public static Thread thread; /// <summary> /// 电池电量变化事件,供界面调用 /// </summary> public static event EventHandler batteryEvent; /// <summary> /// 信号变化事件,供界面调用 /// </summary> public static event EventHandler signalEvent; /// <summary> /// 信号强度枚举 /// </summary> public enum Signal { VeryHigh, High, Medium, Low, VeryLow } /// <summary> /// 当前电量 /// </summary> public static int powerValue = 1; /// <summary> /// 当前信号强度 /// </summary> public static int signalValue = 1; private static int temp; static Battery_signal() { thread = new Thread(new ThreadStart(getBattery)); thread.Start(); } private static void getBattery() { while (true) { switch (SystemState.PowerBatteryStrength) { case BatteryLevel.VeryHigh: { if (powerValue != 5) { powerValue = 5; batteryEvent.Invoke(5, null); } } break; case BatteryLevel.High: { if (powerValue != 4) { powerValue = 4; batteryEvent.Invoke(4, null); } } break; case BatteryLevel.Medium: { if (powerValue != 3) { powerValue = 3; batteryEvent.Invoke(3, null); } } break; case BatteryLevel.Low: { if (powerValue != 2) { powerValue = 2; batteryEvent.Invoke(2, null); } } break; case BatteryLevel.VeryLow: { if (powerValue != 1) { powerValue = 1; batteryEvent.Invoke(1, null); } } break; } temp = SystemState.PhoneSignalStrength; if (temp > 80) { if (signalValue != 5) { signalValue = 5; signalEvent.Invoke(5, null); } } else if (temp > 60) { if (signalValue != 4) { signalValue = 4; signalEvent.Invoke(4, null); } } else if (temp > 40) { if (signalValue != 3) { signalValue = 3; signalEvent.Invoke(3, null); } } else if (temp > 20) { if (signalValue != 2) { signalValue = 2; signalEvent.Invoke(2, null); } } else { if (signalValue != 1) { signalValue = 1; signalEvent.Invoke(1, null); } } Thread.Sleep(1000); } } }