Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 1998-09-22
5
Medium Priority
?
155 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

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…
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…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

636 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