I have a need to retrieve a list of attached USB HID devices and query their details to populate a list. .Net makes it easy to get a list of devices:
using (var searcher = new ManagementObjectSearcher(@"Select * From Win32_PnPEntity Where PNPDeviceID like 'HID%'"))
collection = searcher.Get();
I can then iterate over the items in the collection and query the properties. Unfortunately the properties do not include the device friendly name e.g. "Big Image Inc Reader".
Is there a native .Net way to get properties such as the friendly name?
I have code that can do this in C++ using DeviceIOControl etc, and it might be that the best approach is to write a non managed C++ wrapper class and invoke it from C#. But native code woud be 'cleaner'.
I have a shared dll (model.dll) and two executables using it. In teh model library i have a property. In the one executable i would like to set [ReadOnlyAttribute(false)] for the property and in the other executable i would like to set [ReadOnlyAttribute(true)]. Using the conditional compilation settings in the respertive project properties does not do the trick. Does anybody have a suggestion for me?
Conditional compilation is just that: a compile time operation.
If you have two exes using the same DLL, then they will have the same attributes, because the compilation is only done once and the same assembly is being referenced. You can't use it to switch attribute settings at run time!
If you want two different attribute settings, then you need to build two separate DLL files - which kinda defeats the point of having it as a DLL in the first place!
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...