Ejemplo n.º 1
0
 private static extern bool SetupDiGetDeviceRegistryProperty(
     IntPtr DeviceInfoSet,
     ref SP_DEVINFO_DATA DeviceInfoData,
     RegPropertyType Property,
     out int PropertyRegDataType,
     byte[] PropertyBuffer,
     int PropertyBufferSize,
     out int RequiredSize
     );
Ejemplo n.º 2
0
 public static extern unsafe int SetupDiGetDeviceRegistryProperty(
     int DeviceInfoSet,
     ref SP_DEVINFO_DATA DeviceInfoData,
     RegPropertyType Property,
     int *PropertyRegDataType,
     ref DATA_BUFFER PropertyBuffer,
     int PropertyBufferSize,
     ref int RequiredSize
     );
Ejemplo n.º 3
0
 public extern static bool SetupDiGetDeviceRegistryProperty(
     IntPtr deviceInfoSet,
     ref SP_DEVINFO_DATA deviceInfoData,
     RegPropertyType property,
     out UInt32 propertyRegDataType,
     StringBuilder DeviceInstanceId,
     uint propertyBufferSize,
     out UInt32 requiredSize
     );
Ejemplo n.º 4
0
        private static bool TryGetDeviceFriendlyName(IntPtr aDeviceInfoHandle, SP_DEVINFO_DATA aDeviceInfoData, RegPropertyType regProperty, out string aFriendlyName)
        {
            byte[] valueBuffer          = new byte[255];
            int    propertyRegDataType  = 0;
            var    friendlyNameByteSize = 255;

            aFriendlyName = "";

            // Get the size of the friendly device name

            var success = SetupDiGetDeviceRegistryProperty(
                aDeviceInfoHandle,       // handle to device information set
                ref aDeviceInfoData,     // pointer to SP_DEVINFO_DATA structure
                regProperty,             // property to be retrieved
                out propertyRegDataType, // pointer to variable that receives the data type of the property
                valueBuffer,             // pointer to PropertyBuffer that receives the property
                friendlyNameByteSize,    // size, in bytes, of the PropertyBuffer buffer.
                out friendlyNameByteSize);
            var error = Marshal.GetLastWin32Error();

            if (success)
            {
                aFriendlyName = System.Text.UTF8Encoding.Default.GetString(valueBuffer, 0, friendlyNameByteSize - 1);
                DebugLogger.WriteLine(aFriendlyName);
                return(success);
            }

            throw new Win32Exception(error);
        }
Ejemplo n.º 5
0
 internal static extern bool SetupDiGetDeviceRegistryProperty(IntPtr DeviceInfoSet, ref SP_DEVINFO_DATA DeviceInfoData, RegPropertyType Property, out UInt32 PropertyRegDataType, IntPtr PropertyBuffer, int PropertyBufferSize, out UInt32 RequiredSize);
Ejemplo n.º 6
0
        private static bool TryGetDeviceFriendlyName(IntPtr aDeviceInfoHandle, SP_DEVINFO_DATA aDeviceInfoData, RegPropertyType regProperty, out string aFriendlyName)
        {
            byte[] valueBuffer = new byte[255];
            int propertyRegDataType = 0;
            var friendlyNameByteSize = 255;

            aFriendlyName = "";

            // Get the size of the friendly device name
           
            var success = SetupDiGetDeviceRegistryProperty(
                aDeviceInfoHandle,     // handle to device information set
                ref aDeviceInfoData,       // pointer to SP_DEVINFO_DATA structure
                regProperty,           // property to be retrieved
                out propertyRegDataType,   // pointer to variable that receives the data type of the property
                valueBuffer,                   // pointer to PropertyBuffer that receives the property
                friendlyNameByteSize,                     // size, in bytes, of the PropertyBuffer buffer.
                out friendlyNameByteSize);
            var error = Marshal.GetLastWin32Error();
            if (success)
            {
                aFriendlyName = System.Text.UTF8Encoding.Default.GetString(valueBuffer,0,friendlyNameByteSize-1);
                DebugLogger.WriteLine(aFriendlyName);
                return success;
            }

            throw new Win32Exception(error);
        }
Ejemplo n.º 7
0
 private static extern bool SetupDiGetDeviceRegistryProperty(
     IntPtr DeviceInfoSet,
     ref SP_DEVINFO_DATA DeviceInfoData,
     RegPropertyType Property,
     out int PropertyRegDataType,
     byte[] PropertyBuffer,
     int PropertyBufferSize,
     out int RequiredSize
 );