?
Solved

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

Posted on 1998-09-22
5
Medium Priority
?
153 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 300 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

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month8 days, 19 hours left to enroll

765 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