是否有可能让我的c#wpf程序知道用户是否有触摸屏?

我有一个登录应用程序,它有一个滑动系统,人们只有在有触摸屏时才能使用。 他们可以通过刷他们的个人模式滑动代码登录。

如果用户有触摸屏,是否可以签入C#或WPF? 即使他当时没有使用触控function?

在C#代码中,通过在PresentationCore使用System.Windows.Input命名空间来查明是否存在触摸屏(不检查是否是单个或多点触控设备)。

  public bool HasTouchInput() { foreach (TabletDevice tabletDevice in Tablet.TabletDevices) { //Only detect if it is a touch Screen not how many touches (ie Single touch or Multi-touch) if(tabletDevice.Type == TabletDeviceType.Touch) return true; } return false; } 

我不认为托管代码中有任何可用的东西,但您可以在Win32_DesktopMonitor上使用P / Invoke。 有关更多信息,请参阅msdn 。

我发现这篇博文可能会有所帮助,即使它在Windows CE上也是如此: http : //blog.nerdbank.net/2006/10/platform-detection-iii-how-to-detect.html

Windows XP Tablet PC Edition中有IInkTablet2 COM接口,或者用于非WPF应用程序的托管包装器Microsoft.Ink.Tablet类。 但它的大多数触摸屏驱动程序都是“鼠标”驱动程序,无法以这种方式检测到。