While both Smartphones and Pocket PCs are based on Windows Mobile, there are some very important differences for developers who are targeting both platforms. Not the least of which are lack of LinkButtons and other clickable elements on Smartphones (since they have no touch screen). In this post I show how to detect whether your app is running on a Smartphone or a Pocket PC style Windows Mobile device.
It is a simple call to SystemParametersInfo to find whether you are running on a Smartphone or a Pocket PC. You need a few constants defined and the P/Invoke marshaling code to make it work from managed code however.
This post builds on the first post in the Platform Detection series. You'll need to build on the code from that post for this post to compile and run. Like the last post, this code uses partial classes, so you can copy and paste the previous post's code into one file and this code into another (removing the first post's Main method) and your project will compile and run.
internal partial class PInvoke
public static string GetPlatformType()
StringBuilder platformType = new StringBuilder(50);
(uint)platformType.Capacity, platformType, 0) == 0)
throw new Exception("Error getting platform type.");
internal partial class PlatformDetection
public static bool IsSmartphone()
return PInvoke.GetPlatformType() == "SmartPhone";
public static bool IsPocketPC()
return PInvoke.GetPlatformType() == "PocketPC";
static void Main(string args)
platform = "Smartphone";
else if (PlatformDetection.IsPocketPC())
platform = "Pocket PC";
platform = "Other WinCE";
MessageBox.Show("Platform: " + platform);
This is the second post in a series of three on platform detection. Coming up next: detecting the presence of a touch screen.