#736 – 通过代码获取硬件支持的最大触摸点数(Finding the Maximum Number of Touch Points at Run-time)

来源:互联网 发布:win7怎么远程控制mac 编辑:程序博客网 时间:2024/05/20 06:04

原文地址;https://wpf.2000things.com/2013/01/17/736-finding-the-maximum-number-of-touch-points-at-run-time/

我们可以使用Win32的API函数GetSystemMetrics 获取硬件支持的最大触摸点数。

class Program{    [DllImport("user32.dll")]    static extern int GetSystemMetrics(int nIndex);     // Index passed in to GetSystemMetrics() indicates    // what data we're asking for.    private const int SM_DIGITIZER = 94;    private const int SM_MAXIMUMTOUCHES = 95;     // Masks used to check results from SM_DIGITIZER check    private const int NID_READY = 0x80;    private const int NID_MULTI_INPUT = 0x40;     static void Main(string[] args)    {        string info;         int digitizer = GetSystemMetrics(SM_DIGITIZER);         if ((digitizer & (NID_READY + NID_MULTI_INPUT)) == NID_READY + NID_MULTI_INPUT)        {            int numTouchPoints = GetSystemMetrics(SM_MAXIMUMTOUCHES);            info = string.Format("Multitouch ready, {0} inputs supported", numTouchPoints);        }        else            info = "Multitouch not supported";         Console.WriteLine(info);        Console.ReadLine();    }}

打印出结果如下:

736-001

你可以在“控制面板”->“系统”页中查看。

阅读全文
0 0
原创粉丝点击