private void EnumerateDiscRecorders() { Guid guidFormatID; IUnknown pUnknown; IEnumDiscRecorders pEnumDiscRecorders; IDiscRecorder pRecorder; string pbstrPath; uint pcFetched; if ((fSupportedFormats == SupportedRecordTypes.sfBoth) || (fSupportedFormats == SupportedRecordTypes.sfData)) { guidFormatID = GUIDS.IID_IJolietDiscMaster; fDiscMaster.SetActiveDiscMasterFormat(ref guidFormatID, out pUnknown); fDataDiscWriter = pUnknown as IJolietDiscMaster; if (fDataDiscWriter != null) { fDiscMaster.EnumDiscRecorders(out pEnumDiscRecorders); pcFetched = 1; pEnumDiscRecorders.Next(1, out pRecorder, out pcFetched); while (pcFetched == 1) { fDataRecorders.Add(pRecorder); pRecorder.GetPath(out pbstrPath); fDataRecorderDrives.Add(pbstrPath); pEnumDiscRecorders.Next(1, out pRecorder, out pcFetched); } } } if (fDataRecorders.Count == 0) { throw new XPBurnException(XPBurn.Resource.NotCDRW); } }
/// <summary> /// Internal constructor. Instances of this class should only /// be obtained from the <see cref="DiscMaster"/> object. /// </summary> /// <param name="owner">Disc master object which owns this object.</param> /// <param name="jolietDiscMaster">Imapi Joliet Disc</param> internal JolietDiscMaster( DiscMaster owner, IJolietDiscMaster jolietDiscMaster ) { if ( owner == null ) { throw new ArgumentNullException( "owner" ); } // End if (owner == null) if ( jolietDiscMaster == null ) { throw new ArgumentNullException( "jolietDiscMaster" ); } // End if (jolietDiscMaster == null) _owner = owner; _jolietDiscMaster = jolietDiscMaster; _rootStorage = new JolietDiscMasterStorage( owner ); }
protected override void Dispose( bool disposing ) { // Check to see if Dispose has already been called. if ( disposing && !IsDisposed ) { // Dispose managed resources. _rootStorage.Dispose(); Marshal.ReleaseComObject( _jolietDiscMaster ); _jolietDiscMaster = null; } base.Dispose( disposing ); }
/// <summary> /// Sets the property value. /// </summary> /// <param name="jolietDiscMaster">The joliet disc master.</param> /// <param name="propertyID">The property ID.</param> /// <param name="value">The value.</param> /// <exception cref="COMException"></exception> /// <exception cref="NoDevicePropertiesException"></exception> /// <exception cref="DiscMasterNotOpenedException"></exception> /// <exception cref="NoActiveFormatException"></exception> /// <exception cref="WrongFormatException"></exception> internal static void SetJolietPropertyValue( IJolietDiscMaster jolietDiscMaster, string propertyID, object value ) { IPropertyStorage ppPropStg; PropSpec rgPropID; object newValue; try { jolietDiscMaster.GetJolietProperties( out ppPropStg ); } catch ( COMException ex ) { Trace.WriteLine( ex.Message + Environment.NewLine + ex.StackTrace ); switch ( (uint) ex.ErrorCode ) { case ErrorCodes.IMAPI_E_DEVICE_NOPROPERTIES: throw new NoDevicePropertiesException(); case ErrorCodes.IMAPI_E_NOTOPENED: throw new DiscMasterNotOpenedException(); case ErrorCodes.IMAPI_E_NOACTIVEFORMAT: throw new NoActiveFormatException(); case ErrorCodes.IMAPI_E_WRONGFORMAT: throw new WrongFormatException(); default: throw; } } newValue = value; rgPropID = new PropSpec(); rgPropID.ulKind = PrpSpec.LPWStr; rgPropID.ID_or_LPWSTR = Marshal.StringToCoTaskMemUni( propertyID ); try { ppPropStg.WriteMultiple( 1, ref rgPropID, ref newValue, 8 ); } catch ( Exception ex ) { Trace.WriteLine( string.Format( CultureInfo.CurrentCulture, "Error setting {0}.{1}{2}{3}{4}", propertyID, Environment.NewLine, ex.Message, Environment.NewLine, ex.StackTrace ) ); throw; } finally { Marshal.FreeCoTaskMem( rgPropID.ID_or_LPWSTR ); } try { jolietDiscMaster.SetJolietProperties( ppPropStg ); } catch ( COMException ex ) { Trace.WriteLine( ex.Message + Environment.NewLine + ex.StackTrace ); switch ( (uint) ex.ErrorCode ) { case ErrorCodes.IMAPI_S_PROPERTIESIGNORED: Trace.WriteLine( Resources.Error_Msg_IMAPI_S_PROPERTIESIGNORED ); break; case ErrorCodes.IMAPI_E_DEVICE_NOPROPERTIES: throw new NoDevicePropertiesException(); case ErrorCodes.IMAPI_E_NOTOPENED: throw new DiscMasterNotOpenedException(); case ErrorCodes.IMAPI_E_NOACTIVEFORMAT: throw new NoActiveFormatException(); case ErrorCodes.IMAPI_E_WRONGFORMAT: throw new WrongFormatException(); default: throw; } } }
/// <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); }