Beispiel #1
0
            public static string GetTrackIsrc(SafeFileHandle hDevice, byte track)
            {
                var req = new SubChannelRequest {
                    Format = MMC.SubChannelRequestFormat.ISRC, Track = track
                };
                var reqlen  = Util.SizeOfStructure <SubChannelRequest>();
                var isrclen = Util.SizeOfStructure <MMC.SubChannelISRC>();

                if (!NativeApi.DeviceIoControl(hDevice, IOCTL.CDROM_READ_Q_CHANNEL, ref req, reqlen, out MMC.SubChannelISRC isrc, isrclen, out int _, IntPtr.Zero))
                {
                    throw new IOException($"Failed to retrieve ISRC for track {track}.", new Win32Exception(Marshal.GetLastWin32Error()));
                }
                isrc.FixUp();
                return(isrc.Status.IsValid ? Encoding.ASCII.GetString(isrc.ISRC) : string.Empty);
            }
Beispiel #2
0
            public static string GetMediaCatalogNumber(SafeFileHandle hDevice)
            {
                var req = new SubChannelRequest {
                    Format = MMC.SubChannelRequestFormat.MediaCatalogNumber, Track = 0
                };
                var reqlen = Util.SizeOfStructure <SubChannelRequest>();
                var mcnlen = Util.SizeOfStructure <MMC.SubChannelMediaCatalogNumber>();

                if (!NativeApi.DeviceIoControl(hDevice, IOCTL.CDROM_READ_Q_CHANNEL, ref req, reqlen, out MMC.SubChannelMediaCatalogNumber mcn, mcnlen, out int _, IntPtr.Zero))
                {
                    throw new IOException("Failed to retrieve media catalog number.", new Win32Exception(Marshal.GetLastWin32Error()));
                }
                mcn.FixUp();
                return(mcn.Status.IsValid ? Encoding.ASCII.GetString(mcn.MCN) : string.Empty);
            }
Beispiel #3
0
 private static extern bool DeviceIoControl(SafeFileHandle hDevice, IOCTL command, ref SubChannelRequest request, int requestSize, out MMC.SubChannelISRC data, int dataSize, out int pBytesReturned, IntPtr overlapped);