Determining the type of a device at runtime II: A single binary solution

Recently, I wrote about a mechanism to identify the type of device on which your application is running.  My original solution utilized a custom unmanaged function to provide a simplified, type safe way to call the SystemParametersInfo function.Some of the folks here commented that, while my method worked and was valid, it was sub-optimal since…

2

Determining the type of a device at runtime

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…

0

Checking for Screen Rotation Support using version 2 of the .NET Compact Framework – Visual Basic .Net version

Last year, I posted a snippet on how to determine whether or not your device supported screen rotation using the .NET Compact Framework.  I have recently been asked for a Visual Basic .NET version of the snippet.  Other than some minor reordering / reformatting, the code below is a direct port of the example from the…

1

Wrapping Unmanaged Resources

I recently wrote about three common causes of memory leaks in managed applications.  In that post, I mentioned that failing to release unmanaged resources was one cause.  Today, I’d like to talk a bit about one approach to working with unmanaged resources that has worked well in my code.Wrapping Unmanaged ResourcesWhile at MEDC 2005, I…

1

Checking for Screen Rotation Support in NetCF version 2

A couple of months ago, I showed an example of how to P/Invoke to check if your device supports device rotation using version 1 of the .NET Compact Framework.  In that post, I promised to revisit the example for NetCF v2 once Beta 2 was released. You may recall that in the previous version of…

4

Is my device running on battery or AC power?

At times, it’s helpful to know if the device running your application is plugged in or on battery power (long duration process, software update, etc).  Since the .NET Compact Framework does not provide a managed implementation for this check, you will need to P/Invoke to the native power status API.  The power status P/Invoke is…

2

How To Get The Display’s Color Depth using NetCF Version 1

I’ve seen this asked about recently on the NetCF (microsoft.public.dotnet.framework.compactframework) newsgroup, and it fits nicely with yesterday’s display related p/invoke, too… 🙂 You may have noticed that, in version 1 of the .NET Compact Framework, the Screen object (System.Windows.Forms.Screen) does not specify the color depth of the display device (Bounds, PrimaryScreen, WorkingArea are provided).  The color…

5

Checking for Screen Rotation Support Using NetCF

Yesterday, the Windows Mobile team posted a handy tip titled “How to check if screen can be rotated”.  This got me interested in checking for screen rotation support from managed code. In V1, the structure to be marshalled is not pretty.  Since the fixed size character arrays are not at the end of the structure (and…

8