Exemple #1
0
        public CDTrack[] ReadTrackInfo()
        {
            using (DriveLock.Lock(this.handle))
            {
                NativeMethods.CDROM_TOC toc;
                uint bytesRead = 0;
                if (NativeMethods.DeviceIoControl(
                        this.handle,
                        (uint)NativeMethods.IOControlCode.IOCTL_CDROM_READ_TOC,
                        IntPtr.Zero,
                        0,
                        out toc,
                        (uint)Marshal.SizeOf(typeof(NativeMethods.CDROM_TOC)),
                        ref bytesRead,
                        IntPtr.Zero) == 0)
                {
                    throw new Exception();
                }

                var tracks = new CDTrack[toc.LastTrack];
                for (var i = toc.FirstTrack - 1; i < toc.LastTrack; i++)
                {
                    tracks[i] = new CDTrack(
                        this.AddressToSector(toc.TrackData[i].Address),
                        this.AddressToSector(toc.TrackData[i + 1].Address));
                }

                return(tracks);
            }
        }
Exemple #2
0
 public IWaveProvider ReadTrack(CDTrack track)
 {
     return(new CdWaveProvider(this.handle, track.StartSector, track.EndSector));
 }