예제 #1
0
 /// <summary>
 /// 被子线程DataArrival事件处理函数发送到控件线程异步执行的函数
 /// </summary>
 /// <param name="Data">接收的字节数组</param>
 /// <param name="Ip">远程主机的IP地址</param>
 /// <param name="Port">远程主机的端口</param>
 private void DataArrival(byte[] Data, IPAddress Ip, int Port)
 {
     try
     {
         //将接收的字节数组反序列化
         ClassMsg msg = new ClassSerializers().DeSerializeBinary(new System.IO.MemoryStream(Data)) as ClassMsg;
         switch (msg.msgCommand)
         {
         case MsgCommand.Registered:                                                                                                   //注册成功
             DialogResult = DialogResult.OK;                                                                                           //设置注册窗口对话框结果属性
             WritePrivateProfileString("MyQQ", "ID", this.txtServer.Text.Trim(), Public_Class.Get_windows() + @"\MyQQServer.ini");     //向INI文件写入ID键值对
             WritePrivateProfileString("MyQQ", "Port", this.txtPort.Text.Trim(), Public_Class.Get_windows() + @"\MyQQServer.ini");     //向INI文件写入Port键值对
             WritePrivateProfileString("MyQQ", "Name", this.txtUserName.Text.Trim(), Public_Class.Get_windows() + @"\MyQQServer.ini"); //向INI文件写入Name键值对
             break;
         }
     }
     catch
     { }
 }