DeviceManagementDeclarations.cs
author sl
Wed, 14 May 2014 07:53:47 +0200
changeset 1 29c8c6738077
permissions -rw-r--r--
Disabling signing to fix our build.
     1 using System;
     2 using System.Runtime.InteropServices; 
     3 
     4 namespace GenericHid
     5 {
     6 	internal sealed partial class DeviceManagement
     7 	{
     8 		internal static class NativeMethods
     9 		{
    10 			///<summary >
    11 			// API declarations relating to device management (SetupDixxx and 
    12 			// RegisterDeviceNotification functions).   
    13 			/// </summary>
    14 
    15 			// from setupapi.h
    16 
    17 			internal const Int32 DIGCF_PRESENT = 2;
    18 			internal const Int32 DIGCF_DEVICEINTERFACE = 0X10;
    19 
    20 			internal struct SP_DEVICE_INTERFACE_DATA
    21 			{
    22 				internal Int32 cbSize;
    23 				internal Guid InterfaceClassGuid;
    24 				internal Int32 Flags;
    25 				internal IntPtr Reserved;
    26 			}
    27 
    28 			internal struct SP_DEVICE_INTERFACE_DETAIL_DATA
    29 			{
    30 				internal Int32 cbSize;
    31 				internal String DevicePath;
    32 			}
    33 
    34 			internal struct SP_DEVINFO_DATA
    35 			{
    36 				internal Int32 cbSize;
    37 				internal Guid ClassGuid;
    38 				internal Int32 DevInst;
    39 				internal Int32 Reserved;
    40 			}
    41 
    42 			[DllImport("setupapi.dll", SetLastError = true)]
    43 			internal static extern IntPtr SetupDiCreateDeviceInfoList(ref Guid ClassGuid, IntPtr hwndParent);
    44 
    45 			[DllImport("setupapi.dll", SetLastError = true)]
    46 			internal static extern Int32 SetupDiDestroyDeviceInfoList(IntPtr DeviceInfoSet);
    47 
    48 			[DllImport("setupapi.dll", SetLastError = true)]
    49 			internal static extern Boolean SetupDiEnumDeviceInterfaces(IntPtr DeviceInfoSet, IntPtr DeviceInfoData, ref Guid InterfaceClassGuid, Int32 MemberIndex, ref SP_DEVICE_INTERFACE_DATA DeviceInterfaceData);
    50 
    51 			[DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Auto)]
    52 			internal static extern IntPtr SetupDiGetClassDevs(ref Guid ClassGuid, IntPtr Enumerator, IntPtr hwndParent, Int32 Flags);
    53 
    54 			[DllImport("setupapi.dll", SetLastError = true, CharSet = CharSet.Auto)]
    55 			internal static extern Boolean SetupDiGetDeviceInterfaceDetail(IntPtr DeviceInfoSet, ref SP_DEVICE_INTERFACE_DATA DeviceInterfaceData, IntPtr DeviceInterfaceDetailData, Int32 DeviceInterfaceDetailDataSize, ref Int32 RequiredSize, IntPtr DeviceInfoData);
    56 		}
    57 	}
    58 }