Saturday
Apr022011
Find out if you are using the Windows Phone Emulator

It is often useful in a Windows Phone program for the code to know whether or not it is running on a real device. It is actually easy to do this:
- Add Microsoft.Phone to the references to your project if it is not already there.
- Put the following line at the top of your program.
using Microsoft.Devices; - You can now write code like this:
if (Microsoft.Devices.Environment.DeviceType ==
DeviceType.Device)
{
// we are running on the real phone
}
You can use DeviceType.Emulator in the test to see if you are running on the emulator.


Reader Comments (4)
i wouldnt mind expanding the control scheme for hardware keyboard devices (venue pro) and / or applying dithering filters to AMOLED screen phones (omnia 7)...
would be a nice touch to improve support on specific hardware
Mechacrash: I believe there are some device properties in the registry that you can use to find out the hardware version. However, I'm not mad keen on this kind of thing. The idea is that Windows Phone is a unified platform and all programs will work in the same way on all devices. I think if you made a program that worked in a markedly different way on each platform you might encounter problems with certification.
the hardware keys available on slider phones werent my main objective, mostly the applied dithering. When i played with the omnia 7 gradients just got ruined.
Ive been told its also because applications cant take advantage of 24bit colouring, but i have no inside proof either way of that :/
thanks for the info anyway, ill try and contact their support regarding it if need be