form1.cs

来自「vs2005 c# wince 查询取得电话状态」· CS 代码 · 共 55 行

CS
55
字号
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.WindowsMobile.Status;
using System.Threading;

namespace PhoneState
{
    public partial class Form1 : Form
    {
        private SystemState callState, callCount;

        public Form1()
        {
            InitializeComponent();
            ListenCall();
        }


        public void ListenCall()
        {
            callState = new SystemState(SystemProperty.PhoneCallTalking);
            callCount = new SystemState(SystemProperty.PhoneActiveCallCount);

            callState.Changed += new ChangeEventHandler(callState_Changed);
            callCount.Changed += new ChangeEventHandler(callCount_Changed);
        }

        void callCount_Changed(object sender, ChangeEventArgs args)
        {
            if (args.NewValue != null && (int)args.NewValue !=0)
             MessageBox.Show("Call Incoming...");
        }

        void callState_Changed(object sender, ChangeEventArgs args)
        {
            if (args.NewValue != null)
            {
                String state = ((int)args.NewValue) == 1 ? "talking..." : "hang up";
                MessageBox.Show(state);
            }
        }








    }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?