如何检测Windows设备是否启用了触摸 [英] How do I detect if a Windows device is touch-enabled

查看:42
本文介绍了如何检测Windows设备是否启用了触摸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检测WinForms应用程序(不是WPF)在c#中是否启用了触摸功能.

How do I detect if a device is touch-enabled in c# for a WinForms app (Not WPF).

我在GetSystemMetrics上找到了信息...找不到在c#中使用它的方法.

I found information on GetSystemMetrics...can't find how to use this in c#.

我尝试使用System.Windows.Input.Tablet类..即使我使用的是.Net Framework 4.5,也没有在c#中出现.

I Tried using System.Windows.Input.Tablet class..not coming up in c#, even though I am using .Net Framework 4.5.

我尝试使用System.Windows.Devices ...即使我使用的是.Net Framework 4.5,也没有在c#中出现.

I Tried using System.Windows.Devices...not coming up in c#, even though I am using .Net Framework 4.5.

我还检查了,似乎会使这个问题重复.但是,这些都不能回答我的问题.

I have also checked This and This, which would seem to make this question a duplicate. However, neither of these answers my question.

推荐答案

GetSystemMetrics似乎是正确的方法.应该通过p/invoke这样访问它:

GetSystemMetrics seems to be the right way to go. It should be accessed through p/invoke like this:

[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;
}

这篇关于如何检测Windows设备是否启用了触摸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆