AMemberofDollars
AMemberofDollars

Reputation: 351

Get Device Information from C# IntPtr

Background/Disclaimer: Im currently working on a C# project that requires interaction with Microsoft's Raw Input API. I am a C# developer and I'm completely new to the Raw Input API 'space' and new to related APIs (i.e. Windows Forms, user32.dll, Windows Programming) in general.

The Question: Due to my background, I prefer to use the Raw Input API through a C# managed wrapper library; I have chosen SharpDX, but I am open to other C# solutions. I've gotten raw input to work, capturing both the keyboard event and a IntPtr representing the keyboard device. Is there a way I can find more information on the device (such as Guid, Product Name, Device Name, etc) with this IntPtr reference?

What has been done so far

  1. Got Raw Input to work via an EventHandler delegate and SharpDX API; got an IntPtr to the device.
  2. For the past 3 days, scoured the internet using my mediocre searching skills; found no C# managed way (safe context) to get device information from a C# IntPtr.

Note: Though a code answer is helpful, I'm not here just to "grab-an-answer-and-run". As long as its possible to do this via some C# managed free library or without a C# 'unsafe' context; sending me links to the documentation of said library and to the library's main site with some general guidelines should suffice.

Upvotes: 2

Views: 1644

Answers (1)

Enfyve
Enfyve

Reputation: 936

In theory, yes, the pointer should be a reference to the handle of the input device, therefore you should be able to invoke GetRawInputDeviceInfo to get the desired information.

You'll have to either import this external function call yourself (from KMoussa's comment), or in your C# managed wrapper of choice.

Upvotes: 2

Related Questions