Detecting when a Pocket PC is docked in a cradle in Windows Mobile 2003

断了今生、忘了曾经 提交于 2019-12-12 01:36:54

问题


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:


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



来源:https://stackoverflow.com/questions/3440517/detecting-when-a-pocket-pc-is-docked-in-a-cradle-in-windows-mobile-2003

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!