views:

88

answers:

1

Is is possible to detect when a Pocket Pc device is docked in it's cradle in Windows Mobile 2003 using C#.

I want it to call a web-service when the device is put back on charge.

+1  A: 

What about this guys answer.

http://social.msdn.microsoft.com/Forums/en-US/vssmartdevicesnative/thread/d7e6d896-ff0b-4bb8-969d-3ff516db6782

OpennetCF provide a way to monitor activesync connection status. Like the code below:

private void connectAsync_Click(object sender, System.EventArgs e)
                {
                        m_rapi.RAPIConnected += new RAPIConnectedHandler(m_rapi_RAPIConnected);
                        m_rapi.RAPIDisconnected += new RAPIConnectedHandler(m_rapi_RAPIDisconnected);
                        m_rapi.Connect(false, -1);
                }

                private void m_rapi_RAPIConnected()
                {
            this.Invoke(textUpdate, new object[] { this, new TextArgs(connectStatus, "Connected") });
            this.Invoke(enableUpdate, new object[] { this, new EnableArgs(connectAsync, false) });
            this.Invoke(enableUpdate, new object[] { this, new EnableArgs(connectSync, false) });
                }

                private void m_rapi_RAPIDisconnected()
                {
            this.Invoke(textUpdate, new object[] { this, new TextArgs(connectStatus, "Not Connected") });
            this.Invoke(enableUpdate, new object[] { this, new EnableArgs(connectAsync, false) });
            this.Invoke(enableUpdate, new object[] { this, new EnableArgs(connectAsync, false) });
                }



                 private void copyFrom_Click(object sender, System.EventArgs e)

                {
                        if(! m_rapi.Connected)
                        {
                                MessageBox.Show("Not connected!");
                                return;
                        }

                        m_rapi.CopyFileFromDevice("f:\\1.jpg", "\\My Documents\\1.jpg", true);

                }

While detecting it is connection, it will change the status as "connected".

For more information: http://social.msdn.microsoft.com/forums/en-US/vssmartdevicesvbcs/thread/44e50105-a0ec-4906-86f8-42c8215b6993/

Best regards, Guang-Ming Bian - MSFT

nportelli
That uses the OpenNetCF Smart Device Framework, is there a way to do it within the standard .Net libraries?
Gordon
Pinvokes I'm sure you can do it. Or maybe something in the ActiveSync docs for it. http://msdn.microsoft.com/en-us/library/aa913418.aspx
nportelli