C#必须加某QQ群才能使用软件

public Form1()
        {
            InitializeComponent();
        }
        [DllImport("user32.dll", EntryPoint = "FindWindow")]
        private static extern IntPtr FindWindow(string IpClassName, string IpWindowName);
        /// <summary>
        /// 找到句柄
        /// </summary>
        /// <param name="IpClassName">类名</param>
        /// <returns></returns>
        public static IntPtr GetHandle(string IpClassName, string IpWindowName)
        {
            return FindWindow(IpClassName, IpWindowName);
        }
        private void Form1_Load(object sender, EventArgs e)
        {

            IntPtr cz = GetHandle("TXGuiFoundation", "HR_2014");//查询是否有此群的聊天窗口,第二个参数是群名,修改群名就行了
            if (cz == IntPtr.Zero)
            {
                MessageBox.Show("请加群后再启动本软件");
                Application.Exit();
            }
          
        }

    原文作者:xtfgha
    原文地址: https://blog.csdn.net/xtfgha/article/details/24718219
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞