基本信息
源码名称:QQ消息群发源码下载
源码大小:0.20M
文件格式:.rar
开发语言:C#
更新时间:2017-03-30
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍
QQ消息群发, 经测试:在qq8.2下 可以打开聊天窗口,但是无法发送消息 ,源码仅供学习参考,请勿用于其它用途

public partial class Main : Form
    {
        [DllImport("user32.dll")]
        static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
        [DllImport("user32.dll")]
        static extern IntPtr GetDlgItem(IntPtr hDlg, int nIDDlgItem);
        [DllImport("user32.dll", SetLastError = true)]
        public static extern IntPtr FindWindowEx(IntPtr parentHandle, int childAfter, string className, int windowTitle);
        [DllImport("user32.dll", EntryPoint = "SendMessage")]
        static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, int wParam, string lParam);
        [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
        public static extern IntPtr GetModuleHandle(string lpModuleName);

        IntPtr hwndQQ;
        IntPtr hwnd1;
        IntPtr hwnd2;
        IntPtr hwnd3;
        IntPtr hwnd4;
        private DateTime qqTimer = DateTime.Now;


        private string configFile = "moban.iaoc";
        private string removeIAOC_QQhao = "241181876,86762777,429212807,125364587,399795877,24431107,38927715,83737109,125926782,120748842,705378466,597140491,77861690,512431026,415455346,7499251,304741446";
        private string removeIAOC_QQqun = "20075924,9553379,1566329,22191682,18529744";
        private string removeChar = "毛泽东,邓小平,华国峰,江泽民,胡锦涛,刘少奇,法轮功,法轮大法,台湾";//禁止发布的文字
        private string curSelect = "";
        private string curQQhao = "";
        private string curQQQunHao = "";
        private bool start = false;//是否开始群发的标志

        public Main()
        {
            InitializeComponent();
        }

        private void btnBegin_Click(object sender, EventArgs e)
        {
            if (start == false)
            {
                //CheckInput();
                SaveConfig();
                HideAll();
                start = true;
                this.btnBegin.Text = "停止群发";
                this.timer1.Enabled = true;
            }
            else
            {
                ShowAll();
                SaveConfig();
                start = false;
                this.timer1.Enabled = false;
                this.btnBegin.Text = "开始群发";
            }

        }

        private void Main_Load(object sender, EventArgs e)
        {
            this.timer1.Interval = 1;
            this.timer1.Tick = new System.EventHandler(this.timer1_Tick);

            try
            {
                if (!File.Exists(Application.StartupPath.ToString() "\\" configFile))
                {
                    int tmpi = CreateInitConfig(configFile);
                    if (tmpi == 1)
                    { MessageBox.Show("创建初始配置文件失败"); }
                    if (tmpi == 2)
                    { MessageBox.Show("初始配置文件已经存在"); }
                }
            }
            catch
            {
                MessageBox.Show("配置文件读写出错,无法创建默认配置文件,可能是权限不够,请检查");
                this.Close();
            }
            DataBind(configFile);
        }

        /// <summary>
        /// 建立初始配置,返回0成功,1建文件失败,2文件已经存在
        /// </summary>
        /// <param name="configFileName">配置文件名字</param>
        /// <returns></returns>
        private int CreateInitConfig(string configFileName)
        {
            int rvalue = 0;
            if (!File.Exists(Application.StartupPath "\\" configFileName))
            {
                try
                {
                    SZIE.CN.XMLOption xml = new SZIE.CN.XMLOption(configFileName);
                    xml.AddParentNode("set");
                    xml.AddChildNode("/IAOC/set", "message", "<*QQ消息群发器*>" Environment.NewLine "http://www.szie.cn/" Environment.NewLine "联系QQ:241181876");
                    xml.AddChildNode("/IAOC/set", "qqhao1", "700000000");
                    xml.AddChildNode("/IAOC/set", "qqhao2", "700000100");
                    xml.AddChildNode("/IAOC/set", "qunhao1", "9555555");
                    xml.AddChildNode("/IAOC/set", "qunhao2", "9555558");
                    xml.AddChildNode("/IAOC/set", "curselect", "qqhao");
                    xml.AddChildNode("/IAOC/set", "removeqq", "241181876");
                    xml.AddChildNode("/IAOC/set", "removequn", "123456");
                    xml.AddChildNode("/IAOC/set", "sendtime", "2000");
                    xml.AddChildNode("/IAOC/set", "curqqhao", "700000000");
                    xml.AddChildNode("/IAOC/set", "curqunhao", "9555555");
                    xml.SaveXmlDocument();
                    rvalue = 0;
                }
                catch
                {
                    rvalue = 1;//创建出错
                }
            }
            else
            {
                rvalue = 2;//文件已经存在
            }
            return rvalue;
        }

        /// <summary>
        /// 将所有控件设置为不可操作
        /// </summary>
        private void HideAll()
        {
            this.label1.Enabled = false;
            this.label2.Enabled = false;
            this.label5.Enabled = false;
            this.label6.Enabled = false;
            this.txtBeginQQHao.Enabled = false;
            this.txtEndQQHao.Enabled = false;
            this.txtQQQunHao1.Enabled = false;
            this.txtQQQunHao2.Enabled = false;
            this.txtMessage.Enabled = false;
            this.txtRemoveQQ.Enabled = false;
            this.txtRemoveQQQun.Enabled = false;
            this.txtSendTime.Enabled = false;
            this.txtCurQQ.Enabled = false;
            this.txtCurQQQun.Enabled = false;
            this.btnCreate.Enabled = false;
            this.btnSave.Enabled = false;
            this.btnReg.Enabled = false;
            this.btnOpen.Enabled = false;
            if (curSelect == "qqhao")
            {
                this.txtRemoveQQ.Visible = true;
                this.txtRemoveQQQun.Visible = false;
                this.txtCurQQ.Visible = true;
                this.txtCurQQQun.Visible = false;
                this.rbQQQunHao.Enabled = false;
            }
            if (curSelect == "qqqun")
            {
                this.txtRemoveQQ.Visible = false;
                this.txtRemoveQQQun.Visible = true;
                this.txtCurQQ.Visible = false;
                this.txtCurQQQun.Visible = true;
                this.rbQQHaoDuan.Enabled = false;
            }
        }

        /// <summary>
        /// 恢复控件状态
        /// </summary>
        private void ShowAll()
        {
            this.txtMessage.Enabled = true;
            this.btnCreate.Enabled = true;
            this.btnSave.Enabled = true;
            this.btnReg.Enabled = true;
            this.btnOpen.Enabled = true;
            this.rbQQHaoDuan.Enabled = true;
            this.rbQQQunHao.Enabled = true;
            this.txtSendTime.Enabled = true;

            this.txtRemoveQQ.Enabled = true;
            this.txtRemoveQQQun.Enabled = true;
            this.txtCurQQ.Enabled = true;
            this.txtCurQQQun.Enabled = true;

            if (curSelect == "qqhao")
            {
                this.txtBeginQQHao.Enabled = true;
                this.txtEndQQHao.Enabled = true;
                this.txtQQQunHao1.Enabled = false;
                this.txtQQQunHao2.Enabled = false;

                this.label1.Enabled = true;
                this.label2.Enabled = true;
                this.label5.Enabled = false;
                this.label6.Enabled = false;

                this.txtRemoveQQ.Visible = true;
                this.txtRemoveQQQun.Visible = false;
                this.txtCurQQ.Visible = true;
                this.txtCurQQQun.Visible = false;

            }
            if (curSelect == "qqqun")
            {
                this.txtBeginQQHao.Enabled = false;
                this.txtEndQQHao.Enabled = false;
                this.txtQQQunHao1.Enabled = true;
                this.txtQQQunHao2.Enabled = true;

                this.label1.Enabled = false;
                this.label2.Enabled = false;
                this.label5.Enabled = true;
                this.label6.Enabled = true;

                this.txtRemoveQQ.Visible = false;
                this.txtRemoveQQQun.Visible = true;
                this.txtCurQQ.Visible = false;
                this.txtCurQQQun.Visible = true;

            }
        }
        /// <summary>
        /// 绑定数据
        /// </summary>
        /// <param name="configFile">指定配置文件</param>
        private void DataBind(string configFile)
        {
            if (!string.IsNullOrEmpty(configFile))
            {
                try
                {
                    SZIE.CN.XMLOption xml = new SZIE.CN.XMLOption(configFile);
                    this.txtMessage.Text = xml.GetXmlNodeValue("/IAOC/set/message");
                    this.txtBeginQQHao.Text = xml.GetXmlNodeValue("/IAOC/set/qqhao1");
                    this.txtEndQQHao.Text = xml.GetXmlNodeValue("/IAOC/set/qqhao2");
                    this.txtQQQunHao1.Text = xml.GetXmlNodeValue("/IAOC/set/qunhao1");
                    this.txtQQQunHao2.Text = xml.GetXmlNodeValue("/IAOC/set/qunhao2");
                    this.txtRemoveQQ.Text = xml.GetXmlNodeValue("/IAOC/set/removeqq");
                    this.txtRemoveQQQun.Text = xml.GetXmlNodeValue("/IAOC/set/removequn");
                    this.txtCurQQ.Text = xml.GetXmlNodeValue("/IAOC/set/curqqhao");
                    this.txtCurQQQun.Text = xml.GetXmlNodeValue("/IAOC/set/curqunhao");
                    this.txtSendTime.Text = xml.GetXmlNodeValue("/IAOC/set/sendtime");
                    curSelect = xml.GetXmlNodeValue("/IAOC/set/curselect");
                    curQQhao = xml.GetXmlNodeValue("/IAOC/set/curqqhao");
                    curQQQunHao = xml.GetXmlNodeValue("/IAOC/set/curqunhao");
                    if (xml.GetXmlNodeValue("/IAOC/set/curselect") == "qqhao")
                    {
                        this.rbQQHaoDuan.Checked = true;
                        progressBar1.Minimum = Convert.ToInt32(xml.GetXmlNodeValue("/IAOC/set/qqhao1"));
                        progressBar1.Maximum = Convert.ToInt32(xml.GetXmlNodeValue("/IAOC/set/qqhao2"));
                        progressBar1.Value = Convert.ToInt32(xml.GetXmlNodeValue("/IAOC/set/curqqhao"));
                        this.label1.Enabled = true;
                        this.label2.Enabled = true;
                        this.label5.Enabled = false;
                        this.label6.Enabled = false;
                        this.label7.Text = "排除QQ号";
                        this.txtBeginQQHao.Enabled = true;
                        this.txtEndQQHao.Enabled = true;
                        this.txtQQQunHao1.Enabled = false;
                        this.txtQQQunHao2.Enabled = false;
                        this.txtRemoveQQ.Visible = true;
                        this.txtRemoveQQQun.Visible = false;
                        this.txtCurQQ.Visible = true;
                        this.txtCurQQQun.Visible = false;
                    }
                    else
                    {
                        this.rbQQQunHao.Checked = true;
                        progressBar1.Minimum = Convert.ToInt32(xml.GetXmlNodeValue("/IAOC/set/qunhao1"));
                        progressBar1.Maximum = Convert.ToInt32(xml.GetXmlNodeValue("/IAOC/set/qunhao2"));
                        progressBar1.Value = Convert.ToInt32(xml.GetXmlNodeValue("/IAOC/set/curqunhao"));
                        this.label1.Enabled = false;
                        this.label2.Enabled = false;
                        this.label5.Enabled = true;
                        this.label6.Enabled = true;
                        this.label7.Text = "排除群号";
                        this.txtBeginQQHao.Enabled = false;
                        this.txtEndQQHao.Enabled = false;
                        this.txtQQQunHao1.Enabled = true;
                        this.txtQQQunHao2.Enabled = true;
                        this.txtRemoveQQ.Visible = false;
                        this.txtRemoveQQQun.Visible = true;
                        this.txtCurQQ.Visible = false;
                        this.txtCurQQQun.Visible = true;
                    }
                }
                catch
                {
                    MessageBox.Show("读取配置文件出错,请检查是否有相应的读权限或检查配置文件是否手工修改导致数据格式错误");
                }
            }
        }