I have a .net winforms application which some users will run on Win7 tablets. For those users, I want to change certain UI elements to make pen input easier, while leaving t
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
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.
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.