Im using CompactFramework 3.5 on a WindowsCE 5.0 device to create an application that needs to use an active synchronization connection to receive some data.
How can I determine if the mobile device is in the cradle and has an active connection? Is there any PInvoke call for this?
Depends on which side you want to detect the connection. For desktop computers, there are several ActiveSync events that you can connect to. A free, open source Desktop Communication Library can help you.
There are several ways for a device. For WinMo, this is easy - you can use the status and notification broker by clicking the Microsoft.WindowsMobile.Status class .
For universal CE devices, you can P / call CeRunAppAtEvent (which can set an event, not just an application) using NOTIFICATION_EVENT_RS232_DETECTED. These APIs are also enclosed in the OpenNETCF Smart Device Framework , in particular in the DeviceManagement.SerialDeviceDetected Event
You may also find a stand:
get { return SystemState.GetValue(SystemProperty.CradlePresent).Equals(1); }
Ok then this
get { return (int)SystemState.GetValue(SystemProperty.ConnectionsDesktopCount) > 0; }