public StoragePropertyQuery(StoragePropertyId PropertyId, StorageQueryType QueryType = default, byte[] AdditionalParameters = null) => (this.PropertyId, this.QueryType, this.AdditionalParameters) = (PropertyId, QueryType, AdditionalParameters ?? new byte[1]);
/// <summary> /// /// </summary> /// <param name="IoControl"></param> /// <param name="PropertyId"></param> /// <param name="QueryType"></param> /// <param name="AdditionalParameters"></param> /// <param name="descriptor"></param> /// <param name="ReturnBytes"></param> /// <returns></returns> public static bool StorageQueryProperty(this IoControl IoControl, StoragePropertyId PropertyId, StorageQueryType QueryType, byte[] AdditionalParameters, out IStorageDescriptor descriptor, out uint ReturnBytes) { var genericType = PropertyId.GetDestType() ?? typeof(StorageDescriptor); var query = new StoragePropertyQuery(PropertyId, QueryType, AdditionalParameters); var argument = new object[] { IoControl, query, null, null }; var result = (bool)typeof(MassStorageExtensions) .GetMethods(System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Static) .FirstOrDefault(mi => mi.Name == nameof(StorageQueryProperty) && mi.IsGenericMethodDefinition) .MakeGenericMethod(genericType) .Invoke(null, argument); descriptor = (IStorageDescriptor)argument[2]; ReturnBytes = (uint)argument[3]; return(result); }
/// <summary> /// /// </summary> /// <param name="IoControl"></param> /// <param name="PropertyId"></param> /// <param name="QueryType"></param> /// <param name="AdditionalParameters"></param> /// <returns></returns> public static IStorageDescriptor StorageQueryProperty(this IoControl IoControl, StoragePropertyId PropertyId, StorageQueryType QueryType = default, params byte[] AdditionalParameters) { if (!StorageQueryProperty(IoControl, PropertyId, QueryType, AdditionalParameters, out var descriptor, out var ReturnBytes) && ReturnBytes == 0) { Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error()); } return(descriptor); }
public void StorageQueryPropertyTest(IoControl IoControl, StoragePropertyId StoragePropertyId, StorageQueryType StorageQueryType) => Trace.WriteLine(IoControl.StorageQueryProperty(StoragePropertyId, StorageQueryType));