简体   繁体   English

对于Windows Embedded Standard 7上的WinForms应用程序,如何在c#中检测设备是否启用了触控功能

[英]How do I detect if a device is touch-enabled in c# for a WinForms app on Windows Embedded Standard 7

Below code works fine on Windows 7 but not on Windows Embedded Standard 7 : 下面的代码在Windows 7上运行正常,但在Windows Embedded Standard 7上运行不正常:

[System.Runtime.InteropServices.DllImport("user32.dll")]
    public static extern int GetSystemMetrics(int nIndex);

    public static bool isTouchEnabled()
    {
        int MAXTOUCHES_INDEX = 0x95;
        int maxTouches = GetSystemMetrics(MAXTOUCHES_INDEX);

        return maxTouches > 0;
    }

You can try this: 你可以试试这个:

var hasTouch = Windows.Devices.Input
              .PointerDevice.GetPointerDevices()
              .Any(p => p.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Touch);

For more check this reference 有关此更多信息,请参阅

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM