Hello! The task of making analogue AIDA or Speccy , but more simplified. I do on C # , Windows Forms using Environment , the register and DriveInfo .

There were difficulties with the withdrawal of information about the mouse and keyboard. I want to display in the TextBox at least that they are connected, but I have no idea where to look for it. There were thoughts that there is a name in the registry that stores some value of 1 or 0, that they are connected.

The question is: Where to look for information that a mouse and keyboard are connected to the PC.


The program is in working condition (draft)

PS The application should work on different PCs or laptops running Win7 and higher

    1 answer 1

    In the project's References, set the link to System.Management . In the class where you will work, list using System.Management; Console program example:

      static void Main(string[] args) { Console.WriteLine(HasDevice("PointingDevice")); Console.WriteLine(HasDevice("Keyboard")); Console.ReadKey(); } private static bool HasDevice(string typeDevice) { var mObjects = new ManagementObjectSearcher(@"root\cimv2", "SELECT * FROM Win32_" + typeDevice); //выводим разнообразную информацию об устройствах var devices = (from ManagementObject d in mObjects.Get() as ManagementObjectCollection select d); foreach (var item in devices) { foreach (var p in item.Properties) { Console.WriteLine($"{p.Name}==>{p.Value}"); } } //определяем подключено ли устройство var result = (from ManagementObject d in mObjects.Get() as ManagementObjectCollection where d.Properties["Status"].Value.ToString() == "OK" select d).First(); //выводим результат return result != null; } 
    • Okay I will try. Thank you - Alexander