QQ自动登录器using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Xml;
using System.IO;
namespace QQLogin
{
public partial c...
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.Xml;
using System.IO;
namespace QQLogin
{
public partial class QQLogin : Form
{
///
/// QQ帐号信息
///
public List
QQAccountList = new List();
///
/// QQ信息存储文件的路径
///
private string qqInfoPath = Environment.SystemDirectory + Constants.STR_QQ_DATE_FILE_NAME;
public QQLogin()
{
InitializeComponent();
}
///
/// 加载窗体
///
///
///
private void QQLogin_Load(object sender, EventArgs e)
{
QQAccountList.Clear();
initQQAccountList();
initListView();
}
///
/// 关闭程序
///
///
///
private void QQLogin_FormClosing(object sender, FormClosingEventArgs e)
{
//保存当前listView中的QQ信息
QQFileAccess.Set(qqInfoPath, QQAccountList);
}
///
/// 读取QQ信息,初始化QQAccountList
///
private void initQQAccountList()
{
if (!File.Exists(qqInfoPath))
{
//从指定路径创建QQ信息
File.Create(qqInfoPath).Close();
XmlTextWriter xmlWriter = new XmlTextWriter(qqInfoPath, Encoding.UTF8);
xmlWriter.WriteStartDocument();
xmlWriter.Close();
QQAccountList = new List();
}
else
{
//从指定路径读取QQ信息
QQAccountList = QQFileAccess.Get(qqInfoPath);
}
}
///
/// 初始化ListView显示
///
private void initListView()
{
QQInfoListView.Items.Clear();
if (null == QQAccountList)
{
QQAccountList = new List();
return;
}
//循环添加所有QQ信息
foreach (QQAccount qqAcnt in QQAccountList)
{
string name = qqAcnt.Name;
//有昵称时显示昵称,否则显示QQ号码
if (name == null || name.Length == 0)
{
name = qqAcnt.Number;
}
ListViewItem qqItem = new ListViewItem(name);
qqItem.SubItems.Add(qqAcnt.LastLoginDate);
qqItem.Checked = qqAcnt.IsChecked;
//根据是否隐身,显示不同的图标
if (qqAcnt.IsStealth)
{
qqItem.ImageIndex = 0;
}
else
{
qqItem.ImageIndex = 1;
}
QQInfoListView.Items.Add(qqItem);
}
}
///
/// 启动选定帐号
///
///
///
private void btnStrtAcnt_Click(object sender, EventArgs e)
{
if (QQInfoListView.Items.Count == 0)
{
return;
}
//从注册获取QQ主程序的路径
string qqPath = QQLoginRegistry.GetQQRegistryValue(Constants.STR_QQ_REG_KEY_PRGRM_PATH);
//未设置QQ路径错误提示
if (string.IsNullOrEmpty(qqPath))
{
MessageBox.Show(Constants.STR_QQ_WARN_PRGRM_PATH_NULL);
return;
}
//路径设置选择程序不是QQ,提示错误
if (!qqPath.ToLower().EndsWith("qq.exe"))
{
MessageBox.Show(Constants.STR_QQ_WARN_PRGRM_PATH_ERR);
return;
}
//循环登录所有选择的QQ帐号
foreach (ListViewItem qqItem in QQInfoListView.Items)
{
QQAccount qqAcnt = QQAccountList[qqItem.Index];
if (qqItem.Checked)
{
qqAcnt.IsChecked = true;
string strAcntNum = qqAcnt.Number;
string strPsw = qqAcnt.Psword;
bool blAcntSts = qqAcnt.IsStealth;
qqAcnt.LastLoginDate = DateTime.Now.ToLongDateString() + DateTime.Now.ToShortTimeString();
//通过指定参数启动QQ
Process.Start(qqPath, "/START QQUIN:" + strAcntNum + " PWDHASH:" + strPsw + " /STAT:" + (blAcntSts ? "40" : "41"));
}
else
{
qqAcnt.IsChecked = false;
}
}
}
///
/// 创建快捷登录
///
///
///
private void btnCreateLnk_Click(object sender, EventArgs e)
{
if (0 == QQInfoListView.Items.Count || this.QQInfoListView.FocusedItem == null)
{
return;
}
//从注册表获取QQ主程序的路径
string qqPath = QQLoginRegistry.GetQQRegistryValue(Constants.STR_QQ_REG_KEY_PRGRM_PATH);
//获取当前选择的帐号信息
QQAccount acnt = this.QQAccountList[this.QQInfoListView.FocusedItem.Index];
//创建快捷登录脚本
StreamWriter sw = new StreamWriter("C:\\CreateLink.vbs", false, System.Text.Encoding.GetEncoding("GB2312"));
sw.WriteLine("Set C = CreateObject(\"WScript.Shell\")");
sw.WriteLine("DesktopPath = C.SpecialFolders(\"Desktop\")");
//创建桌面快捷方式,快捷方式以QQ昵称或QQ号码命名
sw.WriteLine("Set link = C.CreateShortcut(DesktopPath & \"\\" + (string.IsNullOrEmpty(acnt.Name) ? acnt.Number : acnt.Name) + ".lnk\")");
sw.WriteLine("link.IconLocation = \"" + qqPath + ",0\"");
//QQ启动参数
string temp = "/START QQUIN:" + acnt.Number + " PWDHASH:" + acnt.Psword + " /STAT:" + (acnt.IsStealth ? "40" : "41");
sw.WriteLine("link.Arguments =\"" + temp + "\"");
sw.WriteLine("link.Description = \"QQ自动登录器 - Aspx1\"");
sw.WriteLine("link.TargetPath = \"" + qqPath + "\"");
sw.WriteLine("link.WindowStyle =0");
sw.WriteLine("link.Save");
sw.WriteLine("Dim oFS");
sw.WriteLine("Set oFS = CreateObject(\"Scripting.FileSystemObject\")");
//删除脚本
sw.WriteLine("oFS.DeleteFile \"c:\\CreateLink.vbs\"");
sw.WriteLine("Set OFS = Nothing");
sw.Close();
//启动进程隐藏执行脚本文件
ProcessStartInfo psi = new ProcessStartInfo("c:\\CreateLink.vbs");
psi.WindowStyle = ProcessWindowStyle.Hidden;
Process.Start(psi);
MessageBox.Show("成功创建快捷方式.");
}
///
/// 启动QQ
///
///
///
private void btnStrtQQ_Click(object sender, EventArgs e)
{
//从注册表获取QQ主程序的路径
string qqPath = QQLoginRegistry.GetQQRegistryValue(Constants.STR_QQ_REG_KEY_PRGRM_PATH);
//未设置QQ路径错误提示
if (string.IsNullOrEmpty(qqPath))
{
MessageBox.Show(Constants.STR_QQ_WARN_PRGRM_PATH_NULL);
return;
}
//路径设置选择程序不是QQ,提示错误
if (!qqPath.ToLower().EndsWith("qq.exe"))
{
MessageBox.Show(Constants.STR_QQ_WARN_PRGRM_PATH_ERR);
return;
}
//启动QQ程序
Process.Start(qqPath);
}
///
/// 添加帐号
///
///
///
private void btnAddAcnt_Click(object sender, EventArgs e)
{
AddAccount addAccount = new AddAccount();
if (addAccount.ShowDialog() == DialogResult.OK)
{
QQAccount acnt = addAccount.GetAddQQInfo();
for (int i = 0; i < QQInfoListView.Items.Count; i++)
{
if (acnt.Number == QQInfoListView.Items[i].Text)
{
MessageBox.Show("号码已存在");
return;
}
}
this.QQAccountList.Add(acnt);
initListView();
//保存QQ信息
QQFileAccess.Set(qqInfoPath, QQAccountList);
}
}
///
/// 设置QQ程序路径
///
///
///
private void btnSetting_Click(object sender, EventArgs e)
{
SetPath setQQPath = new SetPath();
setQQPath.ShowDialog();
}
///
/// 显示关于窗体
///
///
///
private void btnAbout_Click(object sender, EventArgs e)
{
About a = new About();
a.ShowDialog();
}
///
/// 退出程序
///
///
///
private void btnExt_Click(object sender, EventArgs e)
{
this.Close();
}
///
/// 修改QQ信息
///
///
///
private void ltvQQInfo_DoubleClick(object sender, EventArgs e)
{
if (0 == QQInfoListView.Items.Count || this.QQInfoListView.FocusedItem == null)
{
return;
}
//获取要修改的QQ号码
string qqAcntNum = QQAccountList[this.QQInfoListView.FocusedItem.Index].Number;
//获取要修改的QQ昵称
string qqName = QQAccountList[this.QQInfoListView.FocusedItem.Index].Name;
AddAccount chgQQAcntInfo = new AddAccount();
chgQQAcntInfo.initChangeStatus(qqName,qqAcntNum);
if (chgQQAcntInfo.ShowDialog() == DialogResult.OK)
{
QQAccount acnt = this.QQAccountList[this.QQInfoListView.FocusedItem.Index];
//删除原有的QQ帐号信息
this.QQAccountList.Remove(acnt);
//添加修改后的信息
this.QQAccountList.Add(chgQQAcntInfo.GetAddQQInfo());
initListView();
//保存QQ信息
QQFileAccess.Set(qqInfoPath, QQAccountList);
}
}
///
/// 菜单删除事件,删除选定的QQ信息
///
///
///
private void ToolStripMenuDelItem_Click(object sender, EventArgs e)
{
if (0 == QQInfoListView.Items.Count || this.QQInfoListView.FocusedItem == null)
{
return;
}
QQAccountList.RemoveAt(QQInfoListView.FocusedItem.Index);
initListView();
}
///
/// 菜单隐身事件,设置QQ隐身或上线
///
///
///
private void ToolStripMenuShowItem_Click(object sender, EventArgs e)
{
if (0 == QQInfoListView.Items.Count || this.QQInfoListView.FocusedItem == null)
{
return;
}
int intSelectItem = this.QQInfoListView.FocusedItem.Index;
this.QQAccountList[intSelectItem].IsStealth = !this.QQAccountList[intSelectItem].IsStealth;
initListView();
}
///
/// 选中行事件
///
///
///
private void ltvQQInfo_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
{
if (0 == QQInfoListView.Items.Count || this.QQInfoListView.FocusedItem == null)
{
return;
}
int intSelectItem = this.QQInfoListView.FocusedItem.Index;
this.QQAccountList[intSelectItem].IsChecked = !this.QQAccountList[intSelectItem].IsChecked;
initListView();
//设置选中行的样式
this.QQInfoListView.Items[intSelectItem].Focused = true;
this.QQInfoListView.Items[intSelectItem].BackColor = Color.Blue;
this.QQInfoListView.Items[intSelectItem].ForeColor = Color.White;
}
}
}
文档已经阅读完毕,请返回上一页!
本文档为【QQ自动登录器】,请使用软件OFFICE或WPS软件打开。作品中的文字与图均可以修改和编辑,
图片更改请在作品中右键图片并更换,文字修改请直接点击文字进行修改,也可以新增和删除文档中的内容。
[版权声明] 本站所有资料为用户分享产生,若发现您的权利被侵害,请联系客服邮件isharekefu@iask.cn,我们尽快处理。
本作品所展示的图片、画像、字体、音乐的版权可能需版权方额外授权,请谨慎使用。
网站提供的党政主题相关内容(国旗、国徽、党徽..)目的在于配合国家政策宣传,仅限个人学习分享使用,禁止用于任何广告和商用目的。