Detecting tablet PC

╄→尐↘猪︶ㄣ 提交于 2019-12-04 15:36:06

A. Use the Windows GetSystemMetricsAPI and pass in SM_TABLETPC as the value of the index. SM_TABLETPC is defined in Winuser.h. The value of SM_TABLETPC is 86.

For web development, you should read the USER_AGENT_STRING environment variable. You can access this Request.ServerVariables collection.

For details of how to use GetSystemMetrics on Tablet PCs running either Windows Vista or Windows XP Tablet PC Edition, refer to Determining Whether a PC is a Tablet PC.

Sources

Determining Whether a PC is a Tablet PC

MSDN Windows Tablet - Frequently Asked Questions

See msdn post. They have a routine in that page

using System.Runtime.InteropServices;
[DllImport("user32.dll")]
private static extern int GetSystemMetrics(int nIndex);
// System metric constant for Windows XP Tablet PC Edition
private const int SM_TABLETPC = 86;
private readonly bool tabletEnabled;

protected bool IsRunningOnTablet()
{
    return (GetSystemMetrics(SM_TABLETPC) != 0);
}

See if this helps.

In addition to the accepted answer you should also give the user the possibility to manually change between tablet and non-tablet mode. The detection could fail or the operating system is not used in the way it was designed too. This can happen on embedded devices which use a non-tablet-OS with special software as also the other way around.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!