Exemple #1
0
        /// <summary>
        /// Retrieves the specified feature page from the device (via GET_CONFIGURATION).
        /// </summary>
        /// <param name="requestedFeature">
        /// Feature page to retrieve. For possible values, see the
        /// FeaturePageType enumeration type.
        /// </param>
        /// <param name="currentFeatureOnly">
        /// Set to True to retrieve the feature page only when it is the current
        /// feature page. Otherwise, False to retrieve the feature page regardless of it being the current feature
        /// page.
        /// </param>
        /// <returns>
        /// Data buffer that contains the feature page. For details of the contents of the
        /// data buffer, see the GET CONFIGURATION command in the latest revision of the MMC specification at
        /// ftp://ftp.t10.org/t10/drafts/mmc5/.
        /// This method removes header information and other non-feature data before filling and sending this buffer.
        /// </returns>
        Byte[] IDiscRecorder2X.GetFeaturePage(FeaturePageType requestedFeature, bool currentFeatureOnly)
        {
            uint   byteSize = 0;
            IntPtr featureDataPtr;

            IDiscRecorder2Ex recorderEx = (IDiscRecorder2Ex)this;

            recorderEx.GetFeaturePage(requestedFeature, currentFeatureOnly, out featureDataPtr, ref byteSize);

            Byte[] featureData = new Byte[byteSize];

            Marshal.Copy(featureDataPtr, featureData, 0, (int)byteSize);
            Marshal.FreeCoTaskMem(featureDataPtr);

            return(featureData);
        }
Exemple #2
0
        public void UpdateMediaStatus()
        {
            int            i;
            IDiscRecorder2 recorder = new MsftDiscRecorder2();

            isSupportedMediaReady   = false;
            isRewritableMedia       = false;
            textSupportedMedia.Text = "";

            if (!driveListBox.IsEnabled)
            {
                insertedMedia.Text = "";
                NextPage.IsEnabled = false;
                return;
            }

            recorder.InitializeDiscRecorder(selectedDrive);
            IDiscFormat2Data dataWriterImage = new MsftDiscFormat2Data();

            try
            {
                dataWriterImage.Recorder = recorder;
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                if ((uint)e.ErrorCode == 0xC0AA0407) //E_IMAPI_DF2DATA_RECORDER_NOT_SUPPORTED
                {
                    insertedMedia.Text = "";
                    NextPage.IsEnabled = false;
                    return;
                }
            }

            int nf, nsec;

            try{
                nf   = dataWriterImage.FreeSectorsOnMedia;
                nsec = dataWriterImage.TotalSectorsOnMedia;
            }
            catch (System.Runtime.InteropServices.COMException)
            {
            }

            IDiscRecorder2Ex rc2 = recorder as IDiscRecorder2Ex;

            byte[] resp = new byte[1024];
            uint   sb   = 1024;
            IntPtr respPtr;

            rc2.GetFeaturePage(IMAPI_FEATURE_PAGE_TYPE.IMAPI_FEATURE_PAGE_TYPE_PROFILE_LIST, true, out respPtr, ref sb);
            if (sb > 1024)
            {
                sb = 1024;
            }
            Marshal.Copy(respPtr, resp, 0, (int)sb);

            for (i = 4; i < (int)sb; i += 4)
            {
                if (resp[i + 2] != 0)
                {
                    textSupportedMedia.Text += "*";
                    isSupportedMediaReady    = true;
                }
                switch (resp[i + 1])
                {
                case 9:
                    textSupportedMedia.Text += "CD-R ";
                    break;

                case 10:
                    textSupportedMedia.Text += "CD-RW ";
                    break;

                case 17:
                    textSupportedMedia.Text += "DVD-R ";
                    break;

                case 18:
                    textSupportedMedia.Text += "DVD-RAM ";
                    break;

                case 19:
                    textSupportedMedia.Text += "DVD-RW ";
                    break;

                case 21:
                    textSupportedMedia.Text += "DVD-R_DL ";
                    break;

                case 26:
                    textSupportedMedia.Text += "DVD+RW ";
                    break;

                case 27:
                    textSupportedMedia.Text += "DVD+R ";
                    break;

                case 43:
                    textSupportedMedia.Text += "DVD+R_DL ";
                    break;

                case 65:
                    textSupportedMedia.Text += "BD-R ";
                    break;

                case 67:
                    textSupportedMedia.Text += "BD-RE ";
                    break;
                }
            }

            IMAPI_MEDIA_PHYSICAL_TYPE n;

            try
            {
                n = dataWriterImage.CurrentPhysicalMediaType;
                switch (n)
                {
                case IMAPI_MEDIA_PHYSICAL_TYPE.IMAPI_MEDIA_TYPE_CDROM:
                    insertedMedia.Text = "CD-ROM or Audio CD";
                    isCD = true;
                    isBD = false;
                    break;

                case IMAPI_MEDIA_PHYSICAL_TYPE.IMAPI_MEDIA_TYPE_CDR:
                    insertedMedia.Text    = Properties.Resources.MediaType_BlankCDR;//"Blank CD-R";
                    isSupportedMediaReady = true;
                    isCD = true;
                    isBD = false;
                    break;

                case IMAPI_MEDIA_PHYSICAL_TYPE.IMAPI_MEDIA_TYPE_CDRW:
                    insertedMedia.Text    = "CD-RW";
                    isSupportedMediaReady = true;
                    isRewritableMedia     = true;
                    isCD = true;
                    isBD = false;
                    break;

                case IMAPI_MEDIA_PHYSICAL_TYPE.IMAPI_MEDIA_TYPE_DVDDASHRW:
                    insertedMedia.Text    = Properties.Resources.MediaType_DVDRW;
                    isSupportedMediaReady = true;
                    isRewritableMedia     = true;
                    isCD = false;
                    isBD = false;
                    break;

                case IMAPI_MEDIA_PHYSICAL_TYPE.IMAPI_MEDIA_TYPE_DVDDASHR:
                    insertedMedia.Text    = Properties.Resources.MediaType_BlankDVDR;//"Blank DVD-R";
                    isSupportedMediaReady = true;
                    isCD = false;
                    isBD = false;
                    break;

                case IMAPI_MEDIA_PHYSICAL_TYPE.IMAPI_MEDIA_TYPE_DVDROM:
                    insertedMedia.Text = Properties.Resources.MediaType_DVDROM;
                    isCD = false;
                    isBD = false;
                    break;

                case IMAPI_MEDIA_PHYSICAL_TYPE.IMAPI_MEDIA_TYPE_DVDPLUSR:
                    insertedMedia.Text    = Properties.Resources.MediaType_BlankDVDPlusR;//"Blank DVD+R";
                    isSupportedMediaReady = true;
                    isCD = false;
                    isBD = false;
                    break;

                case IMAPI_MEDIA_PHYSICAL_TYPE.IMAPI_MEDIA_TYPE_DVDPLUSRW:
                    insertedMedia.Text    = Properties.Resources.MediaType_DVDPlusRW;
                    isSupportedMediaReady = true;
                    isRewritableMedia     = true;
                    isCD = false;
                    isBD = false;
                    break;

                case IMAPI_MEDIA_PHYSICAL_TYPE.IMAPI_MEDIA_TYPE_DVDRAM:     //IMAPI_PROFILE_TYPE_DVD_RAM:
                    insertedMedia.Text    = Properties.Resources.MediaType_DVDRAM;
                    isSupportedMediaReady = true;
                    isCD = false;
                    isBD = false;
                    isRewritableMedia = true;
                    break;

                case IMAPI_MEDIA_PHYSICAL_TYPE.IMAPI_MEDIA_TYPE_BDR:
                    insertedMedia.Text    = Properties.Resources.MediaType_BlankBDR;
                    isSupportedMediaReady = true;
                    isCD = false;
                    isBD = true;
                    break;

                case IMAPI_MEDIA_PHYSICAL_TYPE.IMAPI_MEDIA_TYPE_BDRE:
                    insertedMedia.Text    = "BD-RE";
                    isSupportedMediaReady = true;
                    isRewritableMedia     = true;
                    isCD = false;
                    isBD = true;
                    break;

                case IMAPI_MEDIA_PHYSICAL_TYPE.IMAPI_MEDIA_TYPE_DVDDASHR_DUALLAYER:
                    insertedMedia.Text    = Properties.Resources.MediaType_BlankDVDR_DL;
                    isSupportedMediaReady = true;
                    isCD = false;
                    isBD = false;
                    break;

                case IMAPI_MEDIA_PHYSICAL_TYPE.IMAPI_MEDIA_TYPE_DVDPLUSR_DUALLAYER:
                    insertedMedia.Text    = Properties.Resources.MediaType_BlankDVDPlusR_DL;
                    isSupportedMediaReady = true;
                    isCD = false;
                    isBD = false;
                    break;

                default:
                    insertedMedia.Text = Properties.Resources.MediaType_UnknownMedia;
                    break;
                }
            }
            catch (System.Runtime.InteropServices.COMException e)
            {
                if ((uint)e.ErrorCode == 0xC0AA0202)                                          //E_IMAPI_RECORDER_MEDIA_NO_MEDIA
                {
                    insertedMedia.Text = Properties.Resources.MediaTypeError_NoMediaInserted; //"No media inserted.";
                }
                else if ((uint)e.ErrorCode == 0xC0AA02FF)                                     //E_IMAPI_RECORDER_INVALID_RESPONSE_FROM_DEVICE
                {
                    insertedMedia.Text = Properties.Resources.MediaTypeError_InvalidResponseFromDevice;
                }
                else
                {
                    insertedMedia.Text = "No media detected due to internal error.";
                }
            }
            if (isSupportedMediaReady)
            {
                NextPage.IsEnabled = true;
            }
            else
            {
                NextPage.IsEnabled = false;
            }

            if (isBD)
            {
                //aaa = dataWriterImage.TotalSectorsOnMedia;
                //aaa = dataWriterImage.FreeSectorsOnMedia;
            }
        }