如何在 C# 中为 WinForms 应用(非 WPF)检测设备是否支持触摸。
我在
GetSystemMetrics
上找到了信息。但我找不到如何在 C# 中使用它。我尝试使用
System.Windows.Input.Tablet
类。但它不会出现在 C# 中,即使我使用的是 .NET Framework 4.5。我尝试使用
System.Windows.Devices
。但它不会出现在 C# 中,即使我使用的是 .NET Framework 4.5。我也检查了Detect whether a Windows 8 Store App has a touch screen和 How to detect a touch enabled device (Win 8, C#.NET) ,这似乎使这个问题重复。但是,这些都不能回答我的问题。
最佳答案
GetSystemMetrics
似乎是正确的方法。它应该像这样通过 P/Invoke 访问:
[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern int GetSystemMetrics(int nIndex);
public static bool IsTouchEnabled()
{
const int MAXTOUCHES_INDEX = 95;
int maxTouches = GetSystemMetrics(MAXTOUCHES_INDEX);
return maxTouches > 0;
}
关于c# - 如何检测 Windows 设备是否支持触控,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27803965/