コード例 #1
0
        public static bool TryGetHidInfo(SafeFileHandle hidHandle, out int vendorId, out int productId)
        {
            // create an attributes struct and initialize the size
            NativeMethods.HIDD_ATTRIBUTES attrib = new NativeMethods.HIDD_ATTRIBUTES();
            attrib.Size = Marshal.SizeOf(attrib);

            // get the attributes of the current device
            if (NativeMethods.HidD_GetAttributes(hidHandle.DangerousGetHandle(), ref attrib))
            {
                // if the vendor and product IDs match up
                vendorId  = attrib.VendorID;
                productId = attrib.ProductID;
                return(true);
            }
            else
            {
                vendorId  = 0;
                productId = 0;
                return(false);
            }
        }
コード例 #2
0
        public static bool TryGetHidInfo(SafeFileHandle hidHandle, out int vendorId, out int productId)
        {
            // create an attributes struct and initialize the size
            NativeMethods.HIDD_ATTRIBUTES attrib = new NativeMethods.HIDD_ATTRIBUTES();
            attrib.Size = Marshal.SizeOf(attrib);

            // get the attributes of the current device
            if (NativeMethods.HidD_GetAttributes(hidHandle.DangerousGetHandle(), ref attrib))
            {
                // if the vendor and product IDs match up
                vendorId = attrib.VendorID;
                productId = attrib.ProductID;
                return true;
            }
            else
            {
                vendorId = 0;
                productId = 0;
                return false;
            }
        }