Solved

CD Identify ??

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now