textBox1.Text = SystemState.CradlePresent.ToString();
自动改变:
using Microsoft.WindowsMobile;
using Microsoft.WindowsMobile.Status;
namespace SmartDeviceProject1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public static SystemState mSystemState;
// 当状态改变时触发事件
void mSystemState_Changed(object sender, ChangeEventArgs args)
{
// SystemState.CradlePresent : Gets a value indicating whether the device is connected to a cradle.
textBox1.Text = SystemState.CradlePresent.ToString();
// 未连线时显示 False
// 连线时显示 True
}
private void Form1_Load(object sender, EventArgs e)
{
// 加入事件
mSystemState = new SystemState(SystemProperty.CradlePresent);
mSystemState.Changed += new ChangeEventHandler(mSystemState_Changed);
mSystemState_Changed(null, null);
}
}