Win32Hid.cs
changeset 77 fb9ea5ad8c2d
parent 76 831ebeeecfdf
     1.1 --- a/Win32Hid.cs	Sun Mar 15 14:39:21 2015 +0100
     1.2 +++ b/Win32Hid.cs	Sun Mar 15 14:45:40 2015 +0100
     1.3 @@ -22,7 +22,7 @@
     1.4  using Microsoft.Win32.SafeHandles;
     1.5  using System.Text;
     1.6  
     1.7 -namespace Win32
     1.8 +namespace SharpLib.Win32
     1.9  {
    1.10  
    1.11      static partial class Function
    1.12 @@ -42,7 +42,7 @@
    1.13          /// Return Type: NTSTATUS->LONG->int
    1.14          ///PreparsedData: PHIDP_PREPARSED_DATA->_HIDP_PREPARSED_DATA*
    1.15          ///Capabilities: PHIDP_CAPS->_HIDP_CAPS*
    1.16 -        [DllImportAttribute("hid.dll", EntryPoint = "HidP_GetCaps", CallingConvention = CallingConvention.StdCall)]
    1.17 +        [DllImport("hid.dll", EntryPoint = "HidP_GetCaps", CallingConvention = CallingConvention.StdCall)]
    1.18          public static extern HidStatus HidP_GetCaps(System.IntPtr PreparsedData, ref HIDP_CAPS Capabilities);
    1.19  
    1.20          /// Return Type: NTSTATUS->LONG->int
    1.21 @@ -50,7 +50,7 @@
    1.22          ///ButtonCaps: PHIDP_BUTTON_CAPS->_HIDP_BUTTON_CAPS*
    1.23          ///ButtonCapsLength: PUSHORT->USHORT*
    1.24          ///PreparsedData: PHIDP_PREPARSED_DATA->_HIDP_PREPARSED_DATA*
    1.25 -        [System.Runtime.InteropServices.DllImportAttribute("hid.dll", EntryPoint = "HidP_GetButtonCaps", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
    1.26 +        [DllImport("hid.dll", EntryPoint = "HidP_GetButtonCaps", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
    1.27          public static extern HidStatus HidP_GetButtonCaps(HIDP_REPORT_TYPE ReportType, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] HIDP_BUTTON_CAPS[] ButtonCaps, ref ushort ButtonCapsLength, System.IntPtr PreparsedData);
    1.28  
    1.29          /// Return Type: NTSTATUS->LONG->int
    1.30 @@ -58,7 +58,7 @@
    1.31          ///ValueCaps: PHIDP_VALUE_CAPS->_HIDP_VALUE_CAPS*
    1.32          ///ValueCapsLength: PUSHORT->USHORT*
    1.33          ///PreparsedData: PHIDP_PREPARSED_DATA->_HIDP_PREPARSED_DATA*
    1.34 -        [System.Runtime.InteropServices.DllImportAttribute("hid.dll", EntryPoint = "HidP_GetValueCaps", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
    1.35 +        [DllImport("hid.dll", EntryPoint = "HidP_GetValueCaps", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
    1.36          public static extern HidStatus HidP_GetValueCaps(HIDP_REPORT_TYPE ReportType, [Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 2)] HIDP_VALUE_CAPS[] ValueCaps, ref ushort ValueCapsLength, System.IntPtr PreparsedData);
    1.37  
    1.38          /// Return Type: NTSTATUS->LONG->int
    1.39 @@ -70,7 +70,7 @@
    1.40          ///PreparsedData: PHIDP_PREPARSED_DATA->_HIDP_PREPARSED_DATA*
    1.41          ///Report: PCHAR->CHAR*
    1.42          ///ReportLength: ULONG->unsigned int
    1.43 -        [System.Runtime.InteropServices.DllImportAttribute("hid.dll", EntryPoint = "HidP_GetUsageValue", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
    1.44 +        [DllImport("hid.dll", EntryPoint = "HidP_GetUsageValue", CallingConvention = System.Runtime.InteropServices.CallingConvention.StdCall)]
    1.45          public static extern HidStatus HidP_GetUsageValue(HIDP_REPORT_TYPE ReportType, ushort UsagePage, ushort LinkCollection, ushort Usage, ref uint UsageValue, System.IntPtr PreparsedData, [MarshalAs(UnmanagedType.LPArray)] byte[] Report, uint ReportLength);
    1.46  
    1.47  
    1.48 @@ -142,7 +142,7 @@
    1.49      }
    1.50  
    1.51  
    1.52 -    [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
    1.53 +    [StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]
    1.54      public struct HIDP_CAPS
    1.55      {
    1.56          /// USAGE->USHORT->unsigned short
    1.57 @@ -161,7 +161,7 @@
    1.58          public ushort FeatureReportByteLength;
    1.59  
    1.60          /// USHORT[17]
    1.61 -        [System.Runtime.InteropServices.MarshalAsAttribute(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst = 17, ArraySubType = System.Runtime.InteropServices.UnmanagedType.U2)]
    1.62 +        [MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValArray, SizeConst = 17, ArraySubType = System.Runtime.InteropServices.UnmanagedType.U2)]
    1.63          public ushort[] Reserved;
    1.64  
    1.65          /// USHORT->unsigned short
    1.66 @@ -198,7 +198,7 @@
    1.67      /// <summary>
    1.68      /// Type created in place of an anonymous struct
    1.69      /// </summary>
    1.70 -    [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
    1.71 +    [StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]
    1.72      public struct HIDP_BUTTON_CAPS_RANGE
    1.73      {
    1.74  
    1.75 @@ -230,7 +230,7 @@
    1.76      /// <summary>
    1.77      /// Type created in place of an anonymous struct
    1.78      /// </summary>
    1.79 -    [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
    1.80 +    [StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]
    1.81      public struct HIDP_BUTTON_CAPS_NOT_RANGE
    1.82      {
    1.83  
    1.84 @@ -262,7 +262,7 @@
    1.85      /// <summary>
    1.86      /// 
    1.87      /// </summary>
    1.88 -    [StructLayoutAttribute(LayoutKind.Explicit, Pack = 1)]
    1.89 +    [StructLayout(LayoutKind.Explicit, Pack = 1)]
    1.90      public struct HIDP_BUTTON_CAPS
    1.91      {
    1.92          /// USAGE->USHORT->unsigned short
    1.93 @@ -275,7 +275,7 @@
    1.94  
    1.95          /// BOOLEAN->BYTE->unsigned char
    1.96          [FieldOffset(3)]
    1.97 -        [MarshalAsAttribute(UnmanagedType.U1)]
    1.98 +        [MarshalAs(UnmanagedType.U1)]
    1.99          public bool IsAlias;
   1.100  
   1.101          /// USHORT->unsigned short
   1.102 @@ -296,27 +296,27 @@
   1.103  
   1.104          /// BOOLEAN->BYTE->unsigned char
   1.105          [FieldOffset(12)]
   1.106 -        [MarshalAsAttribute(UnmanagedType.U1)]
   1.107 +        [MarshalAs(UnmanagedType.U1)]
   1.108          public bool IsRange;
   1.109  
   1.110          /// BOOLEAN->BYTE->unsigned char
   1.111          [FieldOffset(13)]
   1.112 -        [MarshalAsAttribute(UnmanagedType.U1)]
   1.113 +        [MarshalAs(UnmanagedType.U1)]
   1.114          public bool IsStringRange;
   1.115  
   1.116          /// BOOLEAN->BYTE->unsigned char
   1.117          [FieldOffset(14)]
   1.118 -        [MarshalAsAttribute(UnmanagedType.U1)]
   1.119 +        [MarshalAs(UnmanagedType.U1)]
   1.120          public bool IsDesignatorRange;
   1.121  
   1.122          /// BOOLEAN->BYTE->unsigned char
   1.123          [FieldOffset(15)]
   1.124 -        [MarshalAsAttribute(UnmanagedType.U1)]
   1.125 +        [MarshalAs(UnmanagedType.U1)]
   1.126          public bool IsAbsolute;
   1.127  
   1.128          /// ULONG[10]
   1.129          [FieldOffset(16)]
   1.130 -        [MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst = 10, ArraySubType = UnmanagedType.U4)]
   1.131 +        [MarshalAs(UnmanagedType.ByValArray, SizeConst = 10, ArraySubType = UnmanagedType.U4)]
   1.132          public uint[] Reserved;
   1.133  
   1.134          /// Union Range/NotRange
   1.135 @@ -330,7 +330,7 @@
   1.136      /// <summary>
   1.137      /// Type created in place of an anonymous struct
   1.138      /// </summary>
   1.139 -    [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
   1.140 +    [StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]
   1.141      public struct HIDP_VALUE_CAPS_RANGE
   1.142      {
   1.143  
   1.144 @@ -362,7 +362,7 @@
   1.145      /// <summary>
   1.146      /// Type created in place of an anonymous struct
   1.147      /// </summary>
   1.148 -    [System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
   1.149 +    [StructLayout(System.Runtime.InteropServices.LayoutKind.Sequential)]
   1.150      public struct HIDP_VALUE_CAPS_NOT_RANGE
   1.151      {
   1.152  
   1.153 @@ -395,7 +395,7 @@
   1.154      /// <summary>
   1.155      /// 
   1.156      /// </summary>
   1.157 -    [StructLayoutAttribute(LayoutKind.Explicit, Pack = 1)]
   1.158 +    [StructLayout(LayoutKind.Explicit, Pack = 1)]
   1.159      public struct HIDP_VALUE_CAPS
   1.160      {
   1.161  
   1.162 @@ -409,7 +409,7 @@
   1.163  
   1.164          /// BOOLEAN->BYTE->unsigned char
   1.165          [FieldOffset(3)]
   1.166 -        [MarshalAsAttribute(UnmanagedType.U1)]
   1.167 +        [MarshalAs(UnmanagedType.U1)]
   1.168          public bool IsAlias;
   1.169  
   1.170          /// USHORT->unsigned short
   1.171 @@ -430,27 +430,27 @@
   1.172  
   1.173          /// BOOLEAN->BYTE->unsigned char
   1.174          [FieldOffset(12)]
   1.175 -        [MarshalAsAttribute(UnmanagedType.U1)]
   1.176 +        [MarshalAs(UnmanagedType.U1)]
   1.177          public bool IsRange;
   1.178  
   1.179          /// BOOLEAN->BYTE->unsigned char
   1.180          [FieldOffset(13)]
   1.181 -        [MarshalAsAttribute(UnmanagedType.U1)]
   1.182 +        [MarshalAs(UnmanagedType.U1)]
   1.183          public bool IsStringRange;
   1.184  
   1.185          /// BOOLEAN->BYTE->unsigned char
   1.186          [FieldOffset(14)]
   1.187 -        [MarshalAsAttribute(UnmanagedType.U1)]
   1.188 +        [MarshalAs(UnmanagedType.U1)]
   1.189          public bool IsDesignatorRange;
   1.190  
   1.191          /// BOOLEAN->BYTE->unsigned char
   1.192          [FieldOffset(15)]
   1.193 -        [MarshalAsAttribute(UnmanagedType.U1)]
   1.194 +        [MarshalAs(UnmanagedType.U1)]
   1.195          public bool IsAbsolute;
   1.196  
   1.197          /// BOOLEAN->BYTE->unsigned char
   1.198          [FieldOffset(16)]
   1.199 -        [MarshalAsAttribute(UnmanagedType.U1)]
   1.200 +        [MarshalAs(UnmanagedType.U1)]
   1.201          public bool HasNull;
   1.202  
   1.203          /// UCHAR->unsigned char