Solved

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

Posted on 1998-09-22
5
149 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

770 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