Reference: Use the. net cf library to determine the connection status of the device.

Source: Internet
Author: User

Problem: msdn forums: ActiveSync connection status

The description is as follows:

How to capture the current status of connecting to ActiveSync. For example, if there is a connection, it is true, and if there is no connection, it is false.

I have tried activesyncstatus. Synchronizing and systemstate. activesyncstatus.

Neither of them can determine whether the PDA is connected to ActiveSync.

Solution:

Use the systemstate. cradlepresent attribute: gets a value indicating whether the device is connected to a cradle.

When using Microsoft. windowsmobile, Microsoft. windowsmobile. status must be referenced.

Code

The following code retrieves and displays the status of the systemstate. cradlepresent attribute when a button is clicked:

 

Button#click
Using System;
Using System. LINQ;
Using System. Collections. Generic;
Using System. componentmodel;
Using System. Data;
Using System. drawing;
Using System. text;
Using System. Windows. forms;

Using Microsoft. windowsmobile. status;
Namespace Smartdeviceproject7
{
Public   Partial   Class Form1: Form
{
Public Form1 ()
{
Initializecomponent ();
}

Private   Void Button#click ( Object Sender, eventargs E)
{
// Systemstate. cradlepresent: gets a value indicating whether the device is connected to a cradle.
Textbox1.text = Systemstate. cradlepresent. tostring ();
// False when no connection is established
// Show true when connecting lines
}
}
}

 

The following code gets and displays the status of the systemstate. cradlepresent attribute when the system status changes

 

Msystemstate_changed
Using System;
Using System. LINQ;
Using System. Collections. Generic;
Using System. componentmodel;
Using System. Data;
Using System. drawing;
Using System. text;
Using System. Windows. forms;

Using Microsoft. windowsmobile. status;
Namespace Smartdeviceproject7
{
Public   Partial   Class Form1: Form
{
Public Form1 ()
{
Initializecomponent ();
}

Systemstate msystemstate;

// Event triggered when the status changes
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 when no connection is established
// Show true when connecting lines
}

Private   Void Form1_load ( Object Sender, eventargs E)
{
// Add event
Msystemstate =   New Systemstate (systemproperty. cradlepresent );
Msystemstate. Changed + =   New Changeeventhandler (msystemstate_changed );
Msystemstate_changed ( Null , Null );
}
}
}

 

ArticleReference:

Systemstate. cradlepresent adequacy

How to Get ActiveSync status in smart device

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.