I'm calling the GetSystemMetrics API call from C# using the following DllImport signature:
[DllImport("user32.dll", SetLastError = true)]
internal static extern int GetSystemMetrics(SystemMetric smIndex);
The SystemMetric enum is (for the most part) taken from pinvoke.net.
For my needs, I am calling GetSystemMetrics twice, once with SM_TABLETPC (86) and again with SM_MEDIACENTER (87). Running both of these calls on a Windows XP machine returned the correct results, however running them on a Vista (32-bit) machine seems to return incorrect results.
From the MSDN documenation:
SM_TABLETPC:
Nonzero if the current operating system is
- Windows XP Tablet PC edition
- Windows Vista or Windows 7 and the Tablet PC Input service is started
otherwise 0.
SM_MEDIACENTER
Nonzero if the current operating system is the Windows XP, Media Center Edition, zero if not.
The problem I'm seeing is:
- The call to GetSystemMetrics(SM_TABLETPC) is returning 0 on my Vista machine whether the Tablet PC Input service is running or not.
- The call to GetSystemMetrics(SM_MEDIACENTER) is always returning 1.
I can somewhat understand the GetSystemMetrics(SM_MEDIACENTER) call returning 1 since I am running Vista Ultimate, which has media center capabilities built-in, although it would be nice to confirm that this is actually why the call is returning 1. The one I don't understand is why GetSystemMetrics(SM_TABLETPC) returns 0 since the implication is that if you are running Windows Vista or Windows 7 and the Tablet PC Input service is not started it should return 0 but if the service is started it should return 1.
Has anyone else seen or can verify this behavior?