13

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

Shashi
  • 2,860
  • 2
  • 34
  • 45
  • 5
    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 Apr 11 '12 at 16:01
  • @svick: In the desktop, our app behave like client and server, but in the tab and mobile device it behave like client only. – Shashi Apr 12 '12 at 04:28
  • 4
    What happens when the user takes their tablet and puts it in a docking station with a keyboard, mouse, and external monitor? – Raymond Chen Apr 12 '12 at 05:46
  • 1
    Could you define 'Tablet'? Why castrate your app on a tablet? Many Win8 tablets will be fully featured PCs. – jv42 Apr 12 '12 at 08:38
  • 2
    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 Apr 12 '12 at 19:32

3 Answers3

7

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);
Yasser Makram
  • 206
  • 1
  • 3
  • 4
    True. However, look at HP TouchSmart desktops as sold at Walmart and Staples and lots of other stores. They are full desktop PCs, with touch screens. You don't want to accidentally think you're on a tablet just by measuring Touch. – djdanlib Apr 11 '12 at 18:30
5

@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.

Viral Jain
  • 1,004
  • 1
  • 14
  • 30
  • @Mahantesh: If u find this helpful, please add a vote... :) I don't hav many. – Viral Jain Apr 13 '12 at 08:28
  • A desktop PC can have 'battery properties' by connecting a Batterty-Backup/UPS system to it (usually via usb). – hometoast Feb 15 '13 at 16:10
  • @hometoast: Yeah, most definitely, it can have… but their percentage is miniscule / negligible (I'm yet to see 1 let alone use it). I don't mean we should ignore them or something, but then exceptions are always there. And this is just a work around :) – Viral Jain Apr 15 '13 at 03:50
0

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.

Mike Calvert
  • 131
  • 7
  • 4
    It would be a mistake to assume all tablets are ARM. That's true today, but Intel is intent to break into that market. – Mark Ransom Apr 11 '12 at 16:50
  • True, but at that rate what makes a tablet different from a standard PC aside from the hardware? We could check for a lack of mouse or keyboard I suppose or the type. Possibly the screen size? WPF applications typically play nicely with different sized screens so I guess the next question is what is the intent of differentiating between a tablet and a PC – Mike Calvert Apr 11 '12 at 19:59
  • 1
    The original question states "more feature if it running in desktop pc". Since those features weren't defined I can't answer your question. – Mark Ransom Apr 11 '12 at 20:04
  • @MarkRansom: In the desktop, our app behave like client and server, but in the tab and mobile device it behave like client only. I am not differentiating about desktop PC and TAB features. I am differentiating my app features. – Shashi Apr 12 '12 at 04:35