Exemplo n.º 1
0
        private void DetectMedia()
        {
            if (this.cboDevice.SelectedIndex == -1)
            {
                return;
            }
            IDiscRecorder2      tag = (IDiscRecorder2)this.cboDevice.SelectedItem.Tag;
            MsftFileSystemImage msftFileSystemImageClass = null;
            GInterface6         msftDiscFormat2DataClass = null;

            try
            {
                try
                {
                    msftDiscFormat2DataClass = (GInterface6)(new MsftDiscFormat2DataClass());
                    if (msftDiscFormat2DataClass.IsCurrentMediaSupported(tag))
                    {
                        msftDiscFormat2DataClass.Recorder = tag;
                        IMAPI_MEDIA_PHYSICAL_TYPE currentPhysicalMediaType = msftDiscFormat2DataClass.CurrentPhysicalMediaType;
                        this.lblMedia.Text       = this.cdUtil.GetMediaTypeString(currentPhysicalMediaType);
                        msftFileSystemImageClass = (MsftFileSystemImage)(new MsftFileSystemImageClass());
                        msftFileSystemImageClass.ChooseImageDefaultsForMediaType(currentPhysicalMediaType);
                        if (!msftDiscFormat2DataClass.MediaHeuristicallyBlank)
                        {
                            msftFileSystemImageClass.MultisessionInterfaces = msftDiscFormat2DataClass.MultisessionInterfaces;
                            msftFileSystemImageClass.ImportFileSystem();
                        }
                        this._totalDiscSize       = 2048L * (long)msftFileSystemImageClass.FreeMediaBlocks;
                        this.btn_BurnDisc.Enabled = true;
                    }
                    else
                    {
                        this.lblMedia.Text  = LangCtrl.GetString("lblMedia", "NO MEDIA");
                        this._totalDiscSize = 0L;
                        return;
                    }
                }
                catch (COMException cOMException1)
                {
                    COMException cOMException = cOMException1;
                    MessageBox.Show(this, cOMException.Message, "Detect Media Error", MessageBoxButtons.OK, MessageBoxIcon.Hand);
                }
            }
            finally
            {
                if (msftDiscFormat2DataClass != null)
                {
                    Marshal.ReleaseComObject(msftDiscFormat2DataClass);
                }
                if (msftFileSystemImageClass != null)
                {
                    Marshal.ReleaseComObject(msftFileSystemImageClass);
                }
            }
            this.UpdateCapacity();
        }
Exemplo n.º 2
0
        public bool DetectMedia(ListItem li, ref Label lbl)
        {
            bool flag = false;

            lbl.Text = string.Empty;
            MsftFileSystemImage msftFileSystemImage      = null;
            GInterface6         msftDiscFormat2DataClass = null;
            IDiscRecorder2      tag = (IDiscRecorder2)li.Tag;

            try
            {
                try
                {
                    msftDiscFormat2DataClass = (GInterface6)(new MsftDiscFormat2DataClass());
                    if (msftDiscFormat2DataClass.IsCurrentMediaSupported(tag))
                    {
                        msftDiscFormat2DataClass.Recorder = tag;
                        lbl.Text = this.GetMediaTypeString(msftDiscFormat2DataClass.CurrentPhysicalMediaType);
                        flag     = true;
                    }
                    else
                    {
                        lbl.Text = "No Media";
                    }
                }
                catch (COMException cOMException)
                {
                }
            }
            finally
            {
                if (msftDiscFormat2DataClass != null)
                {
                    Marshal.ReleaseComObject(msftDiscFormat2DataClass);
                }
                if (msftFileSystemImage != null)
                {
                    Marshal.ReleaseComObject(msftFileSystemImage);
                }
            }
            return(flag);
        }