Solved

CD Identify ??

Posted on 1998-08-04
5
243 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

829 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