コード例 #1
0
ファイル: CDDrive.cs プロジェクト: metalbass/LibDayInstaller
 /// <summary>
 /// Open the CD drive door
 /// </summary>
 /// <returns>True on success</returns>
 public bool EjectCD()
 {
     TocValid = false;
     if (((int)cdHandle != -1) && ((int)cdHandle != 0))
     {
         uint Dummy = 0;
         return(Win32Functions.DeviceIoControl(cdHandle, Win32Functions.IOCTL_STORAGE_EJECT_MEDIA, IntPtr.Zero, 0, IntPtr.Zero, 0, ref Dummy, IntPtr.Zero) != 0);
     }
     else
     {
         return(false);
     }
 }
コード例 #2
0
ファイル: CDDrive.cs プロジェクト: metalbass/LibDayInstaller
 protected bool ReadTOC()
 {
     if (((int)cdHandle != -1) && ((int)cdHandle != 0))
     {
         uint BytesRead = 0;
         TocValid = Win32Functions.DeviceIoControl(cdHandle, Win32Functions.IOCTL_CDROM_READ_TOC, IntPtr.Zero, 0, Toc, (uint)Marshal.SizeOf(Toc), ref BytesRead, IntPtr.Zero) != 0;
     }
     else
     {
         TocValid = false;
     }
     return(TocValid);
 }
コード例 #3
0
ファイル: CDDrive.cs プロジェクト: metalbass/LibDayInstaller
 /// <summary>
 /// Unlock CD drive
 /// </summary>
 /// <returns>True on success</returns>
 public bool UnLockCD()
 {
     if (((int)cdHandle != -1) && ((int)cdHandle != 0))
     {
         uint Dummy = 0;
         Win32Functions.PREVENT_MEDIA_REMOVAL pmr = new Win32Functions.PREVENT_MEDIA_REMOVAL();
         pmr.PreventMediaRemoval = 0;
         return(Win32Functions.DeviceIoControl(cdHandle, Win32Functions.IOCTL_STORAGE_MEDIA_REMOVAL, pmr, (uint)Marshal.SizeOf(pmr), IntPtr.Zero, 0, ref Dummy, IntPtr.Zero) != 0);
     }
     else
     {
         return(false);
     }
 }
コード例 #4
0
ファイル: CDDrive.cs プロジェクト: metalbass/LibDayInstaller
 /// <summary>
 /// Check if there is CD in the drive
 /// </summary>
 /// <returns>True on success</returns>
 public bool IsCDReady()
 {
     if (((int)cdHandle != -1) && ((int)cdHandle != 0))
     {
         uint Dummy = 0;
         if (Win32Functions.DeviceIoControl(cdHandle, Win32Functions.IOCTL_STORAGE_CHECK_VERIFY, IntPtr.Zero, 0, IntPtr.Zero, 0, ref Dummy, IntPtr.Zero) != 0)
         {
             return(true);
         }
         else
         {
             TocValid = false;
             return(false);
         }
     }
     else
     {
         TocValid = false;
         return(false);
     }
 }
コード例 #5
0
ファイル: CDDrive.cs プロジェクト: metalbass/LibDayInstaller
        /// <summary>
        /// Read Audio Sectors
        /// </summary>
        /// <param name="sector">The sector where to start to read</param>
        /// <param name="Buffer">The length must be at least CB_CDDASECTOR*Sectors bytes</param>
        /// <param name="NumSectors">Number of sectors to read</param>
        /// <returns>True on success</returns>
        protected bool ReadSector(int sector, byte[] Buffer, int NumSectors)
        {
            if (TocValid && ((sector + NumSectors) <= GetEndSector(Toc.LastTrack)) && (Buffer.Length >= CB_AUDIO * NumSectors))
            {
                Win32Functions.RAW_READ_INFO rri = new Win32Functions.RAW_READ_INFO();
                rri.TrackMode   = Win32Functions.TRACK_MODE_TYPE.CDDA;
                rri.SectorCount = (uint)NumSectors;
                rri.DiskOffset  = sector * CB_CDROMSECTOR;

                uint BytesRead = 0;
                if (Win32Functions.DeviceIoControl(cdHandle, Win32Functions.IOCTL_CDROM_RAW_READ, rri, (uint)Marshal.SizeOf(rri), Buffer, (uint)NumSectors * CB_AUDIO, ref BytesRead, IntPtr.Zero) != 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }