Log in

View Full Version : Determining the Type of a Device at Runtime


Kris Kumar
03-02-2006, 02:45 PM
<div class='os_post_top_link'><a href='http://blogs.msdn.com/davidklinems/archive/2006/02/28/540740.aspx' target='_blank'>http://blogs.msdn.com/davidklinems/archive/2006/02/28/540740.aspx</a><br /><br /></div><i>"There are times when it is useful for an application to know on what type of device it is running. An application may wish to modify it's user interface depending on device type (suppress button controls on SmartPhone devices, for example), or may be part of a test harness and have a need to log the type of device on which testing was performed. On Win32 platforms, including Windows CE, the function SystemParametersInfo provides a mechanism to get and set system-wide parameters on a device. The data returned by SystemParametersInfo (via the pvParam argument) can vary in type. Depending on the system parameter you request, the function can return a string, an integer, a structure, etc. This makes it a difficult function to call from managed code. We can make it using SystemParametersInfo easier by writing type safe wrappers for the specific system parameters of interest. Today's discussion will do just that for SPI_GETPLATFORMTYPE."</i><br /><br />David Kline is sharing with the developer community a handy code snippet to identify whether the mobile application is running on a Smartphone or a Pocket PC, useful if you are planning to merge the code base for the two into one.