原文地址;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();
}
}
打印出结果如下:
你可以在“控制面板”->“系统”页中查看。