日期:2014-05-20  浏览次数:20900 次

类似于QQ登录怎么实现记住密码账号自动登录呢?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;//FileStream
using System.Runtime.Serialization.Formatters.Binary;
using System.Threading;
using System.ServiceModel;
using System.Runtime.InteropServices;
//using System.Linq;//语言集成查询
namespace IM_CLIENT
{
  public partial class FrmIMLogin : Form
  {  
  public delegate void delgetmsg();
   
  // public FrmIMLogin main = new FrmIMLogin();
  public delegate void delgetsmg();
  public FrmIMLogin()
  {
  InitializeComponent();  
  }

  ServiceReference1.Service1Client svc = null;
  /// <summary>
  /// 登录
  /// </summary>
  /// <param name="sender"></param>
  /// <param name="e"></param>
  private void btn_Login_Click(object sender, EventArgs e)
  {
   
  string name = cmb_Name.Text;//登录用户
  string IP = "127.0.0.1" + DateTime.Now.ToString(""); ///假设IP
  ////
  InstanceContext ctx = new InstanceContext(new FrmIMLogin());
  svc = new ServiceReference1.Service1Client(ctx);
  try
  {
   
   
  if (svc.CheckLoginMsg(name, "pwd", IP).Length < 2)///判断登陆信息!并保存登陆唯一号!
  {
  MessageBox.Show("登陆成功!");
  FrmIMMain Fmain = new FrmIMMain();
  Fmain.ShowDialog();
   
  }
  else if (cmb_Name.Text.Trim()==""||txtbox_Pwd.Text.Trim()=="")
  {
  MessageBox.Show("登陆失败!请检查用户名密码是否正确");
  return;
  }
   
  }
  catch
  {
  MessageBox.Show("服务器没有启动!!");
  return;
  }
  ///登陆验证!
  svc.CheckLoginMsg(cmb_Name.Text, "", "");

  }
   
  /// <summary>
  /// 取消
  /// </summary>
  /// <param name="sender"></param>
  /// <param name="e"></param>
  private void btn_Close_Click(object sender, EventArgs e)
  {
  Application.Exit();
  }
  /// <summary>
  /// 注册账号
  /// </summary>
  /// <param name="sender"></param>
  /// <param name="e"></param>
  private void linkLab_login_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
  {
  System.Diagnostics.Process.Start("IExplore.exe", url);
  }
  /// <summary>
  /// 找回密码
  /// </summary>
  /// <param name="sender"></param>
  /// <param name="e"></param>