Solved

CD Identify ??

Posted on 1998-08-04
5
241 Views
Last Modified: 2010-04-04
Hi...
I write a CD-Player Software in Delphi 3. I also want to add a feature, where you can assign Title Names to each Track and the Player saves it. So my problem is, is there away to detect what CD is inserted, i mean like a serial number ?
0
Comment
Question by:omsec
  • 2
  • 2
5 Comments
 
LVL 1

Accepted Solution

by:
pjdb earned 10 total points
ID: 1359693
You can retireve the disk serial number with GetVolumeInformation. They are unique (I haven't two CD with the same value). I know some CD player that use this number, so it should work.

JDB

0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1359694
Hi omsec,

To get the volume name :

function TCDEvents.GetVolumeName(vDrive: Char): String;
var MaximumComponentLength : dWord;
    FileSystemFlags : dWord;
    VolumeName : String;
    i : integer;
begin
 SetLength(VolumeName, 64);
 GetVolumeInformation(PChar(vDrive+':\'),
                      PChar(VolumeName),
                      Length(VolumeName),
                      nil,
                      MaximumComponentLength,
                      FileSystemFlags,
                      nil,
                      0);
 Result := VolumeName;
end;

To get some other information :

function TCDEvents.GetCDInfo(vWord:Word):String;
var msp : TMCI_INFO_PARMS;
    MediaString : array[0..255] of char;
    ret : longint;
begin
 FillChar(MediaString, SizeOf(MediaString), #0);
 FillChar(msp, sizeof(msp), #0);
 msp.lpstrReturn := @MediaString;
 msp.dwRetSize := 255;
 ret := mciSendCommand(ID,
                       MCI_INFO,
                       vWord,
                       longint(@msp));
 if Ret <> 0 then begin
   MciGetErrorString(ret, @MediaString, SizeOf(MediaString));
   Result := StrPas(MediaString);
 end else Result := StrPas(MediaString);
end;

function TCDEvents.GetSerialNumber: string;
begin
 Result := GetCDInfo(MCI_INFO_MEDIA_IDENTITY);
end;

function TCDEvents.GetUPCNumber: string;
begin
 Result := GetCDInfo(MCI_INFO_MEDIA_UPC);
end;

function TCDEvents.GetProductInfo: string;
begin
 Result := GetCDInfo(MCI_INFO_Product);
end;

Well, this code comes directly from my freeware component cdevents. I'm sure you've seen it around at some places (torries). So, maybe you can check my component out? Any ideas, bugs are welcome.

Zif.
0
 
LVL 2

Author Comment

by:omsec
ID: 1359695
hmh...who deserved the points now ? :P

I'll check out your Compo when I have the URL...
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1359696
hi omsec,

you can find cdevents now also at our own brand-new site! (remember shared effort?). Here is the link :
http://www.delphi.magsoft.com.pl/Download/cdevents.zip

Regards, Zif.
0
 
LVL 1

Expert Comment

by:pjdb
ID: 1359697
who deserved the points now ?
The one that help you most.... it's yours to decide

JDB
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi: how to implement a User Shortcut mapper? 1 110
How to debug For loops? 3 49
How to define IfThen functions in one common unit? 4 54
enhance the following code 3 32
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…
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…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

777 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