Determining Device Type with .NET CF 3.5 ... and more snow

You Can Take it With You

Syndication

News

  • Don't miss the next Windows Mobile Webcast... Unit Testing for Mobile Devices: http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032382824&EventCategory=4&culture=en-US&CountryCode=US.

Before I get to my main point (.NET CF 3.5 feature that simplifies determining the device type) I just need to take a moment and comment on the snow here in New Hampshire. I live in the NH Seacoast area, which may sound funny but NH does have a whopping 13 miles (or is it 15 miles ... hmmm) of Atlantic Ocean coastline. The Seacoast is supposed to be one of the more temperate areas of the state and for the most part it is. But this year things are different.

Now I'm not one to complain about the cold or snow - it's NH ... it's supposed to be cold & snowy. That said this year is different. We've had 4 significant snowfalls in the past two weeks; 3 of them actual snow storms with the snowfall rates reaching over 2 inches/hour. I don't know how much snow we have on the ground in total but I'm certain that it is more snow than we've ever had before Christmas in the 8 years I've lived here. This picture was taken from my (home) office window about 2 hours ago (~2:00 PM EST).

FromJimsOffice

The buried fence there is about 4 feet tall. Some of the depth of the snow built-up on the fence is from the township plowing the sidewalk but most of it is the actual snowfall. I didn't get a picture of my deck but the snow on the deck has now built-up so much that it's reached the bottom of the windows - probably gonna have to dig that down this weekend - And just think ... Winter starts in just 2 days

But that's not why I'm posting...

I don't know how many people have had a chance to checkout What's New in the .NET Compact Framework Version 3.5 - there's a little section entitled Platform ID that's easy to miss but it describes a very important and long-awaited feature: the ability to determine if your application is running on Pocket PC-style device or Smartphone-style device.

Finally we no longer have to P/Invoke out to the SystemParametersInfo native function passing integer constants and StringBuilder instances; it's now just a simple property check: SystemSettings.Platform

if (SystemSettings.Platform == WinCEPlatform.PocketPC)
    txtDeviceType.Text = "Windows Mobile Professional";
else if (SystemSettings.Platform == WinCEPlatform.Smartphone)
    txtDeviceType.Text = "Windows Mobile Standard";
else
    txtDeviceType.Text = "Not Windows Mobile";

Note (21-Dec-2007) - A more complete version of this code snippet is available here.

With this, we can finally check the platform type as easily as we've been able to check the operating system version and CLR version since .NET CF 1.0. To access the SystemSettings class and WinCEPlatform enumeration you'll need to add a reference to the Microsoft.WindowsCE.Forms assembly and provide the necessary using/import for the corresponding namespace.

If you need to make the platform determination in a pre .NET CF 3.5 environment, or if you just like telling stories about how hard things were "back in your day", the How Do I: Detect and Identify a Mobile Device? video provides a complete walkthrough of how to use the SystemParametersInfo native function.

I've been meaning to blog about this for a while (SystemSettings.Platform not snow J) - ah, finally


Posted Dec 20 2007, 02:56 PM by jim-wilson

Comments

Daniel Moth wrote re: Determining Device Type with .NET CF 3.5 ... and more snow
on 12-20-2007 3:15 PM
Old news (click on my blog post from February)

I know this is spam, but sorry I just couldn't resist ;-)
Jim Wilson wrote re: Determining Device Type with .NET CF 3.5 ... and more snow
on 12-21-2007 8:14 AM
Daniel;

Yes but people read my blog. :-)

Just kidding - I know it's old; in fact pretty much anything we talk about in CF 3.5 is gonna be old news. I still think it's worth mentioning.

But I do acknowledge that I should've had this post out a looooooong time ago. :-)

Jim
Daniel Moth wrote re: Determining Device Type with .NET CF 3.5 ... and more snow
on 12-21-2007 8:42 PM
"Yes but people read my blog. :-)"

LOL... I am gonna re-use that one :)
Jim Wilson wrote re: Determining Device Type with .NET CF 3.5 ... and more snow
on 12-24-2007 8:27 AM
Daniel;

I knew you'd accept that comment in the spirit it was offered [ as fun ;-) ].

Have a great Christmas and Holiday week!!

Jim
Catto wrote re: Determining Device Type with .NET CF 3.5 ... and more snow
on 01-08-2008 8:06 AM
Hey Now Jim,
Nice Post. I like the picture of the snow w/ the snag it edge effects. After reading this I learned a good bit about SystemSettings.Platform.
Thx 4 the info,
Catto
Jim Wilson wrote re: Determining Device Type with .NET CF 3.5 ... and more snow
on 01-08-2008 9:35 AM
Catto;

Thanks for your kind words - I'm happy to hear that you found the post useful.

I've just started using Snag It seriously so I was a sucker for using the edge effects. :-)

I wanted to create the image without the square border around the outside of the image but wasn't able to get that worked out in the few minutes I spent on it.

I started using Camtasia Studio only about 7 months ago and as I mentioned just started using Snag It seriously - they've quickly become tools that I can't imagine not having.

Fun weather, fun pictures, fun programming .. I'd say things are looking pretty good. :-)

Thanks,
Jim

Add a Comment

(required)  
(optional)
(required)  
Remember Me?