Determine if Tablet PC — How to determine if my application is running on a Tablet PC

Problem

You want to determine if my application is running on a Tablet PC or a Media Center PC

Solution

Use the GetSystemMetrics Win32 API along with the SM_TABLETPC or SM_MEDIACENTER values.

Discussion

According to the Microsoft Tablet PC SDK:

Q. How can I determine if my application is running on a Tablet PC?

A. Use the Windows GetSystemMetrics API 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. The method returns True or nonzero if the Microsoft Windows XP Tablet PC Edition operating system is running; False or zero otherwise.

Applications should not rely on a true or nonzero value to mean all Tablet PC components are installed and working. See the following question for details on how to determine if Tablet PC components are installed.

There is also a MediaCenter system metrics value.

I would expect System.Windows.Forms.SystemInformation would list both values as it gives most other SystemMetrics, however it appears to be missing TabletPC (SM_TABLETPC) & MediaCenter (SM_MEDIACENTER).

I've used the Tablet PC value reliably, I don't have a Media Center PC to verify the Media Center value.

Example

Determine if your code is running on a Tablet PC

Visual Basic
 
If GetSystemMetrics(SystemMetric.TabletPC) <> 0 Then 
	Debug.WriteLine("On a Tablet PC")
Else
	Debug.WriteLine("Not on a Tablet PC")
End If

Determine if your code is running on a Media Center PC

Visual Basic
 
If GetSystemMetrics(SystemMetric.MediaCenter ) <> 0 Then
	Debug.WriteLine("On a Media Center PC")
Else
	Debug.WriteLine("Not on a Media Center PC")
End If

Source

Define the GetSystemMetrics Win32 API.

Visual Basic
 
Public Enum SystemMetric As Integer
    TabletPC = 86
    MediaCenter = 87
End Enum

Declare Auto Function GetSystemMetrics Lib "User32" (ByVal index As SystemMetric) As Integer