Solved

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

Posted on 1998-09-22
5
151 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
ID: 1340575
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
ID: 1340576
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
ID: 1340577
Can I do it without MediaPlayer ?
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1340578
Haven't tried yet!

//vik
0
 

Expert Comment

by:filyagin
ID: 1340579
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

749 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