Exemplo n.º 1
0
 internal static extern ConfigManagerResult CM_Get_DevNode_Property(
     uint devInst,
     ref DevPropKey propertyKey,
     out DevPropType propertyType,
     IntPtr buffer,
     ref uint bufferSize,
     uint flags);
Exemplo n.º 2
0
        internal static T GetProperty <T>(uint devInst, DevPropKey propertyKey)
        {
            const int bufferSize        = 2048;
            IntPtr    propertyBufferPtr = Marshal.AllocHGlobal(bufferSize);
            uint      propertySize      = bufferSize;

            try
            {
                if (NativeMethods.CM_Get_DevNode_Property(
                        devInst,
                        ref propertyKey,
                        out DevPropType propertyType,
                        propertyBufferPtr,
                        ref propertySize,
                        0) == 0)
                {
                    if (propertySize > 0)
                    {
                        return(DeviceHelper.ConvertPropToType <T>(propertyBufferPtr, propertyType));
                    }
                }
            }
            finally
            {
                Marshal.FreeHGlobal(propertyBufferPtr);
            }

            return(default(T));
        }
Exemplo n.º 3
0
        internal static T GetObjectPropertyInfo <T>(
            IntPtr driverStoreHandle,
            string objectName,
            DevPropKey propertyKey,
            DriverStoreObjectType objectType = DriverStoreObjectType.DriverPackage)
        {
            const int bufferSize        = 2048;
            IntPtr    propertyBufferPtr = Marshal.AllocHGlobal(bufferSize);

            if (NativeMethods.DriverStoreGetObjectProperty(
                    driverStoreHandle,
                    objectType,
                    objectName,
                    ref propertyKey,
                    out DevPropType propertyType,
                    propertyBufferPtr,
                    bufferSize,
                    out uint propertySize,
                    DriverStoreSetObjectPropertyFlags.None))
            {
                if (propertySize > 0)
                {
                    return(DeviceHelper.ConvertPropToType <T>(propertyBufferPtr, propertyType));
                }
            }

            Marshal.FreeHGlobal(propertyBufferPtr);

            return(default);