13
votes

I am developing app with windows 8 metro style. This app has some more feature if it running in desktop pc compared to Tablet. But my problem is how to detect app is running in PC or Tab. I don't want to release 2 build seperately for PC and TAB.

Please help me. Update: Wheter is it possible to do it with GetSystemMatrics? In the desktop, our app behave like client and server, but in the tab and mobile device it behave like client only

3
Why do you care it's a tablet? Does that CPU matter to you? Or the presence of a mouse/keyboard? Or something else?svick
@svick: In the desktop, our app behave like client and server, but in the tab and mobile device it behave like client only.Shashi
What happens when the user takes their tablet and puts it in a docking station with a keyboard, mouse, and external monitor?Raymond Chen
Could you define 'Tablet'? Why castrate your app on a tablet? Many Win8 tablets will be fully featured PCs.jv42
I'll echo the other comments and say that looking at the tablet vs. desktop is the wrong thing to do. You need to look at why you have the distinction - is it that you only want the server on a sufficiently fast CPU? Is it that you don't want to waste battery-life? Is it about the network connection? Is it about touch functionality?Eclipse

3 Answers

7
votes

Windows.Devices namespace has a wealth of information about device capabilities. For example to determine if the device is touch enabled, you can use:

var hasTouch = Windows.Devices.Input
                  .PointerDevice.GetPointerDevices()
                  .Any(p => p.PointerDeviceType == Windows.Devices.Input.PointerDeviceType.Touch);
5
votes

@Mahantesh: If it's specifically between Desktop PC & Tablet (excluding laptop), then you can check the "battery properties" such as AC/Battery Supply, Battery remaining etc. which as far as I know are available only for computers running on battery power & certainly Desktop doesn't do that.

In simpler terms, the battery notification is not available for my Desktop PC whereas it's there for my laptop.

0
votes

My suggestion would be to call down to the GetSystemInfo API in the CoreDLL

Here is an example call:

    [DllImport("coredll")]
    static extern void GetSystemInfo(ref SYSTEM_INFO pSI); 

    public struct SYSTEM_INFO
    {
        public uint dwOemId;
        public uint dwPageSize;
        public uint lpMinimumApplicationAddress;
        public uint lpMaximumApplicationAddress;
        public uint dwActiveProcessorMask;
        public uint dwNumberOfProcessors;
        public uint dwProcessorType;
        public uint dwAllocationGranularity;
        public uint dwProcessorLevel;
        public uint dwProcessorRevision;
    }

If you fetch this information from the tablet, it should return a processor type of 2577 because it is running on ARM processors I believe. You might need to find the specific processor type you are targeting or pass in a list of targeted processor types.