本文整理汇总了C#中DeviceInfo.outputDeviceInfo方法的典型用法代码示例。如果您正苦于以下问题:C# DeviceInfo.outputDeviceInfo方法的具体用法?C# DeviceInfo.outputDeviceInfo怎么用?C# DeviceInfo.outputDeviceInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DeviceInfo
的用法示例。
在下文中一共展示了DeviceInfo.outputDeviceInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getNumOfDevices
public void getNumOfDevices()
{
if (GetRawInputDeviceList(IntPtr.Zero, ref deviceCount, (uint)dwSize) == 0)
{
Console.WriteLine("The number of devices detected: {0}.\n\n", deviceCount);
IntPtr devList = Marshal.AllocHGlobal((int)(dwSize * deviceCount));
GetRawInputDeviceList(devList, ref deviceCount, (uint)dwSize);
for (int i = 0; i < deviceCount; i++)
{
uint pcbSize = 0;
DeviceInfo dInfo;
deviceName = string.Empty;
RAWINPUTDEVICELIST rid = (RAWINPUTDEVICELIST)Marshal.PtrToStructure(new IntPtr((devList.ToInt32() +
(dwSize * i))), typeof(RAWINPUTDEVICELIST));
GetRawInputDeviceInfo(rid.hDevice, RIDI_DEVICENAME, IntPtr.Zero, ref pcbSize);
if (pcbSize > 0)
{
IntPtr pData = Marshal.AllocHGlobal((int)pcbSize);
GetRawInputDeviceInfo(rid.hDevice, RIDI_DEVICENAME, pData, ref pcbSize);
deviceName = (string)Marshal.PtrToStringAnsi(pData);
if (rid.dwType == RIM_TYPEKEYBOARD || rid.dwType == RIM_TYPEHID || rid.dwType == RIM_TYPEMOUSE)
{
dInfo = new DeviceInfo();
dInfo.deviceName = (string)Marshal.PtrToStringAnsi(pData);
dInfo.deviceHandle = rid.hDevice;
dInfo.deviceType = GetDeviceType(rid.dwType);
string DeviceDesc = ReadReg(deviceName);
dInfo.deviceName = DeviceDesc;
Console.WriteLine("Device {0}:", i);
dInfo.outputDeviceInfo();
}
Marshal.FreeHGlobal(pData);
}
}//end for loop
Marshal.FreeHGlobal(devList);
}
else
throw new ApplicationException("Error! Unable to allocate device list buffer.");
}