Example #1
0
        public void WriteImage(BurnVerificationLevel verification, bool finalize, bool eject)
        {
            if (!_recorderLoaded)
            {
                throw new InvalidOperationException("LoadMedia must be called first.");
            }

            MsftDiscRecorder2   recorder       = null;
            MsftDiscFormat2Data discFormatData = null;

            try
            {
                recorder = new MsftDiscRecorder2();
                recorder.InitializeDiscRecorder(_recorders.SelectedItem.InternalUniqueId);

                discFormatData = new MsftDiscFormat2Data
                {
                    Recorder             = recorder,
                    ClientName           = ClientName,
                    ForceMediaToBeClosed = finalize
                };

                //
                // Set the verification level
                //
                var burnVerification = (IBurnVerification)discFormatData;
                burnVerification.BurnVerificationLevel = IMAPI_BURN_VERIFICATION_LEVEL.IMAPI_BURN_VERIFICATION_NONE;

                //
                // Check if media is blank, (for RW media)
                //
                object[] multisessionInterfaces = null;
                if (!discFormatData.MediaHeuristicallyBlank)
                {
                    multisessionInterfaces = discFormatData.MultisessionInterfaces;
                }

                //
                // Create the file system
                //
                IStream fileSystem;
                _CreateImage(recorder, multisessionInterfaces, out fileSystem);

                discFormatData.Update += _discFormatWrite_Update;

                //
                // Write the data
                //
                try
                {
                    discFormatData.Write(fileSystem);
                }
                finally
                {
                    if (fileSystem != null)
                    {
                        Marshal.FinalReleaseComObject(fileSystem);
                    }
                }

                discFormatData.Update -= _discFormatWrite_Update;

                if (eject)
                {
                    recorder.EjectMedia();
                }
            }
            finally
            {
                _isWriting = false;
                if (discFormatData != null)
                {
                    Marshal.ReleaseComObject(discFormatData);
                }
                if (recorder != null)
                {
                    Marshal.ReleaseComObject(recorder);
                }
            }
        }
Example #2
0
        public void WriteImage(BurnVerificationLevel verification, bool finalize, bool eject)
        {
            if (!_recorderLoaded)
                throw new InvalidOperationException("LoadMedia must be called first.");

            MsftDiscRecorder2 recorder = null;
            MsftDiscFormat2Data discFormatData = null;

            try
            {
                recorder = new MsftDiscRecorder2();
                recorder.InitializeDiscRecorder(_recorders.SelectedItem.InternalUniqueId);

                discFormatData = new MsftDiscFormat2Data
                    {
                        Recorder = recorder,
                        ClientName = ClientName,
                        ForceMediaToBeClosed = finalize
                    };

                //
                // Set the verification level
                //
                var burnVerification = (IBurnVerification)discFormatData;
                burnVerification.BurnVerificationLevel = IMAPI_BURN_VERIFICATION_LEVEL.IMAPI_BURN_VERIFICATION_NONE;

                //
                // Check if media is blank, (for RW media)
                //
                object[] multisessionInterfaces = null;
                if (!discFormatData.MediaHeuristicallyBlank)
                    multisessionInterfaces = discFormatData.MultisessionInterfaces;

                //
                // Create the file system
                //
                IStream fileSystem;
                _CreateImage(recorder, multisessionInterfaces, out fileSystem);

                discFormatData.Update += _discFormatWrite_Update;

                //
                // Write the data
                //
                try
                {
                    discFormatData.Write(fileSystem);
                }
                finally
                {
                    if (fileSystem != null) Marshal.FinalReleaseComObject(fileSystem);
                }

                discFormatData.Update -= _discFormatWrite_Update;

                if (eject) recorder.EjectMedia();
            }
            finally
            {
                _isWriting = false;
                if (discFormatData != null) Marshal.ReleaseComObject(discFormatData);
                if (recorder != null) Marshal.ReleaseComObject(recorder);
            }
        }