给好友发消息 查看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.Threading;using PerkySu;namespace WindowsFormsApplication1{ public partial class Form1 : Form { public Form1() { InitializeComponent(); } PerkyQQ objqq = null; private void button1_Click(object sender, EventArgs e) { //在这里写线程内容 objqq = new PerkyQQ(textBox1.Text.Trim(), textBox2.Text.Trim()); if (objqq.QQ_Login()) { foreach (string item in objqq.QQ_List()) { treeView1.Nodes.Add(item.Trim()); } // 启动一个新的子线程加载更详细信息 Thread thread = new Thread( delegate() { //在这里写线程内容 for (int i = 2; i < treeView1.Nodes.Count - 1; i ) { treeView1.Nodes[i].Text = treeView1.Nodes[i].Text objqq.QQ_GetInfo(treeView1.Nodes[i].Text.Trim())[14].ToString(); } } ); thread.Start(); } } private void button2_Click(object sender, EventArgs e) { MessageBox.Show(objqq.QQ_SendMsg(textBox1.Text.Trim(), richTextBox1.Text.Trim()).ToString()); } //查询信息 private void button3_Click(object sender, EventArgs e) { string[] strselectQQ = objqq.QQ_GetInfo(textBox3.Text.Trim()); for (int i = 0; i < strselectQQ.Length; i ) { richTextBox1.Text = strselectQQ[i].ToString(); } } private void Form1_FormClosing(object sender, FormClosingEventArgs e) { Application.Exit(); } //退出QQ private void button2_Click_1(object sender, EventArgs e) { objqq.QQ_Logout(); if (objqq.is_RightLogin) { MessageBox.Show("成功退出"); } else { MessageBox.Show("退出失败"); } } //发消息 private void button4_Click(object sender, EventArgs e) { if (objqq.QQ_SendMsg(textBox3.Text.Trim(), richTextBox1.Text.Trim())) { MessageBox.Show("成功"); } else { MessageBox.Show("失败"); } } //修改状态 private void button7_Click(object sender, EventArgs e) { string strstart = "在线"; if (comboBox1.Text.Trim() == "在线") strstart = "10"; if (comboBox1.Text.Trim() == "离线") strstart = "20"; if (comboBox1.Text.Trim() == "忙碌") strstart = "30"; if (objqq.Change_Stat(strstart.Trim())) { MessageBox.Show("成功"); } else { MessageBox.Show("失败"); } } //删除好友 private void button5_Click(object sender, EventArgs e) { if (MessageBox.Show("您确定要删除这个好友吗,如果删除将不能恢复!!!", "确认", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { if (objqq.DelFromList(textBox3.Text.Trim())) { MessageBox.Show("成功"); } else { MessageBox.Show("失败"); } } } //添加好友 private void button6_Click(object sender, EventArgs e) { if (objqq.AddToList(textBox3.Text.Trim()) == "0") { MessageBox.Show("已是好友"); } else if (objqq.AddToList(textBox3.Text.Trim()) == "1") { MessageBox.Show("需要身份认证请等待"); } else if (objqq.AddToList(textBox3.Text.Trim()) == "2") { MessageBox.Show("对方不请允许添加好友"); } else { MessageBox.Show("未知情况"); } } private void Form1_Load(object sender, EventArgs e) { } }}
评论