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

时间:2015-12-30 05:18:54

标签: c# winforms touch

下面的代码在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;
    }

1 个答案:

答案 0 :(得分:1)

你可以试试这个:

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

有关详情,请查看此reference