如題!效果,當我pda與pc同步之後,我這個服務就能把pda上的文件剪切到電腦某個位置,並重新命名.
這個問題,問了幾天了,也沒有解決方法,麻煩哪個高手走過,留下一個腳印嘛!3Q!

解决方案 »

  1.   

    activesync连接的时候会发送一个消息WM_NETCONNECT,
    在判断wParam   ,如果连接成功,wParam   = 1。
      

  2.   


    這個消息怎麽獲得,能具體說下嗎?
    我在一個窗體裏邊寫,沒有發生消息啊
     protected override void WndProc(ref Message m)
            {
                base.WndProc(ref m);
                Console.Write(m.WParam.ToInt32());
            }
      

  3.   

    我同步数据的时候,一般是先判断能否连上PC上的数据库,如果可以连上,那就说明已经和电脑建立了连接
    判断连接数据库是通过调用webservice来判断
      

  4.   

    http://blog.csdn.net/simalaya/archive/2008/05/22/2469066.aspxC#中似呼要引用一个静态库的了
      

  5.   

    public struct RAPIINIT
        {
            [FieldOffset(0)]
            public int cbsize;
            [FieldOffset(4)]
            public System.IntPtr heRapiInit;
            [FieldOffset(8)]
            public int hrRapiInit;
        };  [DllImport("rapi.dll", CharSet = CharSet.Unicode)]
           public static extern uint CeRapiInitEx([MarshalAs(UnmanagedType.Struct)] ref RAPIINIT pRapiInit);  //判斷是否連接到pc機,並馬上返回結果       [DllImport("kernel32.dll", SetLastError = true)]
           public static extern uint WaitForSingleObject(IntPtr hHandle, int milliseconds); private bool Init()
           {
               RAPIINIT ri=new RAPIINIT();
               ri.cbsize=Marshal.SizeOf(typeof(RAPIINIT));
               uint hInitResult = CeRapiInitEx(ref ri);
               uint dwWaitResult = WaitForSingleObject(ri.heRapiInit, 2000);
               if (hInitResult ==0 && ri.hrRapiInit == 0 && dwWaitResult != 2000)
               {
                  Console.Write(" 连接成功");    //不管我pda是否有連接到pc,都執行到這裏               return true;                 //CeRapiInitEx()不是返回連接成功與否嗎?
               }
               else
               {
                   // 连接不成功
                   Console.Write(" 连接不成功");
                   return false;
               }       }