🟣 C# / .NET 6+
Get Keyboard Info Report (C#)
Queries Win32_Keyboard via WMI (System.Management) and prints Keyboard Info to the console.
GetKeyboardReport.cs
// GetKeyboardReport.cs
//
// Reports Keyboard Info via WMI (Win32_Keyboard).
//
// Requires the System.Management package:
// dotnet new console -o KeyboardReport
// dotnet add package System.Management
// (replace the generated Program.cs with this file, then dotnet run)
// On .NET Framework, System.Management is already available — just
// add a reference to it in your project.
using System;
using System.Management;
var searcher = new ManagementObjectSearcher("SELECT Description, Layout, NumberOfFunctionKeys FROM Win32_Keyboard");
int count = 0;
foreach (ManagementObject item in searcher.Get())
{
Console.WriteLine($"Description: {item["Description"]}");
Console.WriteLine($"Layout: {item["Layout"]}");
Console.WriteLine($"NumberOfFunctionKeys: {item["NumberOfFunctionKeys"]}");
Console.WriteLine(new string('-', 40));
count++;
}
if (count == 0)
{
Console.WriteLine("No Keyboard Info found.");
}
else
{
Console.WriteLine($"\n{count} Keyboard Info found.");
}