Touch screen monitor determination

I am writing an app in C#. I'd like to determine if the user has "Touch Screen" capabilities on their computer. Any suggestions or articles on the topic?
KevinBengoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

it_saigeDeveloperCommented:
Hans Passant provides an answer on another board.  I'll repost the contents of his answer here.
This information is available, the low-level COM interfaces that WPF uses are documented in this MSDN article. A disclaimer is however appropriate, Microsoft doesn't like you to use them. The interface documentation warns "Developers should not use this interface", otherwise without any obvious reason why that's good advice. If Microsoft really wants to prevent us from using it then it would be much simpler to just not document them.

And there's something funky going on with the ITablet2::GetMatchingScreenRect() function, the one you are looking for, the documentation for it missing. In itself a possible reason that this info is not exposed by WPF. So caution is necessary, you do need to test it thoroughly on the hardware you want to use it on. I don't have any to verify.

I wrote some code that uses these interfaces. Add a new class to your project and paste the code shown below. You need to add a reference to System.Drawing.
And his implementation:
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Runtime.InteropServices;

namespace EE_Q28691410
{
	class Program
	{
		static void Main(string[] args)
		{
			var tablets = new TouchTabletCollection();
			for (int ix = 0; ix < tablets.Count; ++ix)
			{
				Console.WriteLine("Found tablet {0} named {1}", ix + 1, tablets[ix].Name);
				Console.WriteLine("  Type = {0}, Multi-touch supported = {1}", tablets[ix].Kind, tablets[ix].IsMultiTouch);
				Console.WriteLine("  Input rectangle  = {0}", tablets[ix].InputRectangle);
				Console.WriteLine("  Screen rectangle = {0}", tablets[ix].ScreenRectangle);
			}
			Console.ReadLine();
		}
	}

	public enum TouchDeviceKind { Mouse, Pen, Touch }

	public class TouchTabletCollection
	{
		public TouchTabletCollection()
		{
			Guid CLSID_TabletManager = new Guid("A5B020FD-E04B-4e67-B65A-E7DEED25B2CF");
			var manager = (ITabletManager)Activator.CreateInstance(Type.GetTypeFromCLSID(CLSID_TabletManager));
			int count = 0;
			manager.GetTabletCount(out count);
			Count = count;
			tablets = new List<TouchTablet>(count);
			for (int index = 0; index < count; index++)
			{
				tablets.Add(new TouchTablet(manager, index));
			}
		}
		public int Count { get; private set; }
		public TouchTablet this[int index]
		{
			get { return tablets[index]; }
		}
		private List<TouchTablet> tablets;
	}

	public class TouchTablet
	{
		internal TouchTablet(ITabletManager mgr, int index)
		{
			ITablet itf;
			mgr.GetTablet(index, out itf);
			device1 = itf;
			device2 = (ITablet2)itf;
			device3 = (ITablet3)itf;
		}
		public bool IsMultiTouch
		{
			get
			{
				bool multi;
				device3.IsMultiTouch(out multi);
				return multi;
			}
		}
		public TouchDeviceKind Kind
		{
			get
			{
				TouchDeviceKind kind;
				device2.GetDeviceKind(out kind);
				return kind;
			}
		}
		public string Name
		{
			get
			{
				IntPtr pname;
				device1.GetName(out pname);
				return Marshal.PtrToStringUni(pname);
			}
		}
		public Rectangle InputRectangle
		{
			get
			{
				RECT rc;
				device1.GetMaxInputRect(out rc);
				return Rectangle.FromLTRB(rc.Left, rc.Top, rc.Right, rc.Bottom);
			}
		}
		public Rectangle ScreenRectangle
		{
			get
			{
				RECT rc;
				device2.GetMatchingScreenRect(out rc);
				return Rectangle.FromLTRB(rc.Left, rc.Top, rc.Right, rc.Bottom);
			}
		}
		private ITablet device1;
		private ITablet2 device2;
		private ITablet3 device3;
	}

	// COM declarations
	[ComImport, Guid("764DE8AA-1867-47C1-8F6A-122445ABD89A")]
	[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
	internal interface ITabletManager
	{
		void GetDefaultTablet(out ITablet table);
		void GetTabletCount(out int count);
		void GetTablet(int index, out ITablet tablet);
		// rest omitted...
	}
	[ComImport, Guid("1CB2EFC3-ABC7-4172-8FCB-3BC9CB93E29F")]
	[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
	internal interface ITablet
	{
		void Dummy1();
		void Dummy2();
		void GetName(out IntPtr pname);
		void GetMaxInputRect(out RECT inputRect);
		void GetHardwareCaps(out uint caps);
		// rest omitted
	}
	[ComImport, Guid("C247F616-BBEB-406A-AED3-F75E656599AE")]
	[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
	internal interface ITablet2
	{
		void GetDeviceKind(out TouchDeviceKind kind);
		void GetMatchingScreenRect(out RECT rect);
	}
	[ComImport, Guid("AC0E3951-0A2F-448E-88D0-49DA0C453460")]
	[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
	internal interface ITablet3
	{
		void IsMultiTouch(out bool multi);
		void GetMaximumCursors(out int cursors);
	}

	internal struct RECT { public int Left, Top, Right, Bottom; }
}

Open in new window

Which produces the following output on a non-touch system -Capture.JPGAnd the following output on a touch based system (All-In-One) -Capture.JPG-saige-

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
KevinBengoAuthor Commented:
Thanks for your answer. It always seems more complicated than it should be when dealing with "What's on my computer?"
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.