Solved

Indentifying a CD when inserted.. is it a DATA or AUDIO CD?

Posted on 1998-09-22
5
148 Views
Last Modified: 2010-04-06
Hi!

My program needs to know what kind of a CD is in drive, when user inserts one... How to make a difference between Data or Audio CD ? And my program needs also to know the label of data cd and track count of possible audio cd..
How do I do that ?
0
Comment
Question by:DjDMac
5 Comments
 
LVL 1

Expert Comment

by:pjdb
Comment Utility
the API function GetVolumeInformation give you the volume name ("audio CD" or any name for data CD).

Don't know about how to obtain the track count

0
 
LVL 10

Accepted Solution

by:
viktornet earned 100 total points
Comment Utility
Here is some stuff on updating the tracks....
----------
interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  MPlayer, StdCtrls, ExtCtrls;

type
  TfrmCDPlayer = class(TForm)
    mmPlayer: TMediaPlayer;
    GroupBox1: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    txtCurrent: TEdit;
    txtNoTracks: TEdit;
    Label3: TLabel;
    Label4: TLabel;
    txtLength: TEdit;
    txtPosition: TEdit;
    Timer1: TTimer;
    procedure FormCreate(Sender: TObject);
    procedure UpdateTracks;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Timer1Timer(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  frmCDPlayer: TfrmCDPlayer;

function BreakDown( nValue : longint ) : string;

implementation

{$R *.DFM}

procedure TfrmCDPlayer.FormCreate(Sender: TObject);
begin
     UpdateTracks;
end;

procedure TfrmCDPlayer.UpdateTracks;
var
   nCurrentTrack : integer;
begin
     with mmPlayer do
     begin
          TimeFormat := tfTMSF;

          nCurrentTrack := Position and 255;

          txtCurrent.text := IntToStr(nCurrentTrack);
          txtNoTracks.text := IntToStr(Tracks);
          txtLength.text := BreakDown(TrackLength[nCurrentTrack]);
          txtPosition.text := BreakDown( Position );

     end;
end;

function BreakDown( nValue : longint ) : string;
var
   nTrack           : integer;
   nMinutes         : integer;
   nSeconds         : integer;
   sResult          : string;
begin

     nTrack := nValue and 255;
     nMinutes := (nValue div 256) and 255;
     nSeconds := (nvalue div 65536) and 255;

     sResult := IntToStr(nTrack) + ':'
                + IntToStr(nMinutes) + ':'
                + IntToStr(nSeconds);

     BreakDown := sResult;

end;


procedure TfrmCDPlayer.FormClose(Sender: TObject;
  var Action: TCloseAction);
begin
     mmPlayer.Stop;
end;

procedure TfrmCDPlayer.Timer1Timer(Sender: TObject);
begin
     UpdateTracks;
end;

end.
-----------
Regards,
Viktor Ivanov
0
 

Author Comment

by:DjDMac
Comment Utility
Can I do it without MediaPlayer ?
0
 
LVL 10

Expert Comment

by:viktornet
Comment Utility
Haven't tried yet!

//vik
0
 

Expert Comment

by:filyagin
Comment Utility
IsAudioCD is the function, which returns true if your CD drive
contains audio disk, and false otherwise.

function IsAudioCD(Drive : Char) : Boolean;
var
  MaximumComponentLength,
  FileSystemFlags        : DWORD;
  DrivePath,
  VolumeName             : string;
begin
  Result := false;
  DrivePath := Drive + ':\';
  if GetDriveType(PChar(DrivePath)) <> DRIVE_CDROM then exit;
  SetLength(VolumeName, 64);
  GetVolumeInformation(PChar(DrivePath), PChar(VolumeName), Length(VolumeName),
    nil, MaximumComponentLength, FileSystemFlags, nil, 0);
  if lStrCmp(PChar(VolumeName),'Audio CD') = 0 then result := true;
end;

0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Suggested Solutions

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now