获取鼠标键数

Posted on 2019-01-17 11:08  努力成长静待花开  阅读(131)  评论(0编辑  收藏  举报

实现效果:

  

知识运用:

  API函数 GetSystemMetrics    //返回与WINDOWS环境有关的信息

实现代码:

        private const int SM_CMOUSEBUTTONS = 43;
        [DllImport("user32.dll", EntryPoint = "GetSystemMetrics")]
        public extern static int GetSystemMetrics(int intcount);
        private void Form1_Load(object sender, EventArgs e)
        {
            int intCon = GetSystemMetrics(SM_CMOUSEBUTTONS);
            label2.Text = intCon + "个";
        }