2

I don't know why I get 6 as a result when I insert a blank media in my burner. To my understanding there is no 6 in the states of the enumeration of IMAPI_FORMAT2_DATA_MEDIA_STATE.

Here is a link that contain this states and the example that I am based on : MSDN:Checking Media Support.

var state = dataWriter.CurrentMediaStatus;                        
Debug.WriteLine((int)state); // outputs 6
Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
habibhassani
  • 486
  • 1
  • 6
  • 15

2 Answers2

4

It's equivalent to a flaggable enum. 6 is 4 + 2, so the state is both

IMAPI_FORMAT2_DATA_MEDIA_STATE_BLANK
IMAPI_FORMAT2_DATA_MEDIA_STATE_APPENDABLE
Jonathon Chase
  • 9,396
  • 21
  • 39
4

It is a combination of both of them, basically a bitwise operation is calculated on the two (or more values). When you make an enum with the attribute Flags then you can do Bitwise operations on it, even though it should work without the attribute

IMAPI_FORMAT2_DATA_MEDIA_STATE_BLANK
IMAPI_FORMAT2_DATA_MEDIA_STATE_APPENDABLE

The value of IMAPI_FORMAT2_DATA_MEDIA_STATE_BLANK with an 'OR' operation with IMAPI_FORMAT2_DATA_MEDIA_STATE_APPENDABLE will give 6 in C# it would be value = 2 | 4;

To go further if you want to test if the value contains a certain Option you can go ahead and do something like this

if ((value & IMAPI_FORMAT2_DATA_MEDIA_STATE_BLANK) == IMAPI_FORMAT2_DATA_MEDIA_STATE_BLANK)
{
//IMAPI_FORMAT2_DATA_MEDIA_STATE_BLANK is contained
}

You can read more about Bitwise operations here

Donald Jansen
  • 1,937
  • 4
  • 22
  • 41
  • ok by the way do you know what happens to the system image, would it be automatically deleted or do i have to do it myself, thanks for your help. – habibhassani Jan 27 '16 at 12:17
  • 1
    I believe you will need you will need to delete it yourself, I have not test that, I guess you will know when you see it is deleted or not. – Donald Jansen Jan 27 '16 at 12:39