Exemple #1
0
        /// <summary>
        /// Dispose(bool disposing) executes in two distinct scenarios.
        /// If disposing equals true, the method has been called directly
        /// or indirectly by a user's code. Managed and unmanaged resources
        /// can be disposed.
        /// </summary>
        /// <param name="disposing">
        /// If disposing equals false, the method has been called by the 
        /// runtime from inside the finalizer and you should not reference 
        /// other objects. Only unmanaged resources can be disposed.
        /// </param>
        protected override void Dispose( bool disposing )
        {
            // Check to see if Dispose has already been called.
            if ( disposing && !IsDisposed )
            {
                // If disposing equals true, dispose all managed
                // and unmanaged resources.
                if ( _jolietDiscMaster != null )
                {
                    _jolietDiscMaster.Dispose();
                }

                if ( _redbookDiscMaster != null )
                {
                    _redbookDiscMaster.Dispose();
                }

                // Dispose managed resources.
                if ( _discMaster != null )
                {
                    if ( _progressEvents != null )
                    {
                        try
                        {
                            _discMaster.ProgressUnadvise( _progressEvents.Cookie );
                        }
                        catch ( COMException ex )
                        {
                            if ( (uint) ex.ErrorCode == ErrorCodes.IMAPI_E_NOTOPENED )
                            {
                                // do not throw an exception in the dispose.
                                Trace.WriteLine( Resources.Error_Msg_IMAPI_E_NOTOPENED );
                            }
                            Trace.WriteLine( ex.Message + Environment.NewLine + ex.StackTrace );
                        }

                        _progressEvents.Dispose();
                        _progressEvents = null;
                    }
                    _discMaster.Close();
                    Marshal.ReleaseComObject( _discMaster );
                    _discMaster = null;
                }

                if ( DiscRecorders != null )
                {
                    DiscRecorders.Dispose();
                }
            }
            base.Dispose( disposing );
        }
Exemple #2
0
        /// <summary>
        /// Instantiate the <c>MsDiscMasterObj</c> implementation, open
        /// it, create progress events and the recorder collection.
        /// </summary>
        /// <exception cref="COMException">if the <c>MsDiscMasterObj</c> implementation
        /// cannot be instantiated.</exception>
        /// <exception cref="DiscMasterAlreadyOpenedException"></exception>
        /// <exception cref="DiscMasterNotOpenedException"></exception>
        private void InitializeImapi()
        {
            _discMaster = IDiscMaster;

            try
            {
                _discMaster.Open();
            }
            catch ( COMException ex )
            {
                Trace.WriteLine( ex.Message + Environment.NewLine + ex.StackTrace );
                if ( (uint) ex.ErrorCode == ErrorCodes.IMAPI_E_ALREADYOPEN )
                {
                    throw new DiscMasterAlreadyOpenedException();
                }
                throw;
            }

            // Set up progress events
            _progressEvents = new DiscMasterProgressEvents( this );
            IntPtr cookie = IntPtr.Zero;
            IDiscMasterProgressEvents iprgEvents = _progressEvents;

            try
            {
                _discMaster.ProgressAdvise( iprgEvents, out cookie );
            }
            catch ( COMException ex )
            {
                Trace.WriteLine( ex.Message + Environment.NewLine + ex.StackTrace );
                if ( (uint) ex.ErrorCode == ErrorCodes.IMAPI_E_NOTOPENED )
                {
                    throw new DiscMasterNotOpenedException();
                }
                throw;
            }

            _progressEvents.Cookie = cookie;

            // Recorders collection
            DiscRecorders = new DiscRecorderCollection( _discMaster );
        }
Exemple #3
0
        /// <summary>
        /// The constructor for the burn component.  This call does a lot of work under the covers,
        /// including communicating with imapi to find out whether there is an XP compatible cd drive attached.
        /// </summary>
        unsafe public XPBurnCD()
        {
            IEnumDiscMasterFormats pEnumDiscFormats;
            uint pcFetched;
            Guid guidFormatID;

            fCancel    = false;
            fIsBurning = false;
            uint  cookieValue = (uint)10;
            uint *tempCookie  = &cookieValue;

            fProgressCookie = &tempCookie;

            Debug.WriteLine(@"8/30/2003 6:59p.m. version 1");

            fMessageQueue = new XPBurnMessageQueue(this);

            fMusicDiscWriter     = null;
            fMusicRecorderDrives = new ArrayList();
            fMusicRecorders      = new ArrayList();
            fDataDiscWriter      = null;
            fDataRecorderDrives  = new ArrayList();
            fDataRecorders       = new ArrayList();

            fFiles = new Hashtable();

            try
            {
                fDiscMaster = (IDiscMaster) new MSDiscMasterObj();
            }
            catch (COMException)
            {
                throw new XPBurnException(Resource.NoMAPI);
            }

            fDiscMaster.Open();

            fDiscMaster.ProgressAdvise(new XPBurnProgressEvents(fMessageQueue), fProgressCookie);

            fDiscMaster.EnumDiscMasterFormats(out pEnumDiscFormats);

            pcFetched = 1;
            while (pcFetched == 1)
            {
                pEnumDiscFormats.Next(1, out guidFormatID, out pcFetched);
                if (guidFormatID == GUIDS.IID_IJolietDiscMaster)
                {
                    fSupportedFormats = ((SupportedRecordTypes)((int)fSupportedFormats | 1));
                }
                else
                {
                    if (guidFormatID == GUIDS.IID_IRedbookDiscMaster)
                    {
                        fSupportedFormats = ((SupportedRecordTypes)((int)fSupportedFormats | 2));
                    }
                }
            }

            if (fSupportedFormats == SupportedRecordTypes.sfNone)
            {
                fDiscMaster.Close();
                throw new XPBurnException(Resource.NoSupport);
            }


            EnumerateDiscRecorders();

            fBurnerDrive  = 0;
            fActiveFormat = RecordType.afData;

            SetDrive(fBurnerDrive);
        }