Solved

CD ID Code

Posted on 1998-09-06
3
153 Views
Last Modified: 2012-05-04
How can i read the id code on a cd, i want to use it to positivly identify each different cd placed in the computer.
0
Comment
Question by:spat
  • 2
3 Comments
 
LVL 4

Accepted Solution

by:
itamar earned 100 total points
ID: 1338828
Hi spat,

the following function is a modification of the original one from Andrea Mennini component TVolumeInformation:

{*****************************************************************************
  function GetVolumeSerialNumber - Gets the Volume serial number for the
                                   specified drive.

  Input parameters: Drive Letter (Example: 'D:'
  Output parameters: The function returns a string containing the volume serial
                     number, or an empty string if some error occurs.
 *****************************************************************************}
function GetVolumeSerialNumber(Drive: string): string;
var
  OldErrorMode: Integer;
  NotUsed, VolFlags: Integer;
  VolSN: DWORD;
  VolumeSerialNumber: string;
  Error: boolean;
begin
  OldErrorMode := SetErrorMode(SEM_FAILCRITICALERRORS);
  try
    //SetUNCDrive;
    Error := GetVolumeInformation(PChar(Drive),
                                  nil,
                                  0,
                                  @VolSN,
                                  NotUsed,
                                  VolFlags,
                                  nil,
                                  0);

    if (Error = False) then
    begin
      //ProcessError(Result);
      Exit
    end;

    VolumeSerialNumber := AnsiUpperCase(IntToHex(VolSN, 8));
    Result := Copy(VolumeSerialNumber, 1, 4) + ':' +
              Copy(VolumeSerialNumber, 5, 4);
  finally
    SetErrorMode(OldErrorMode);
  end;
end;


If you want, I can send you the component with source code. It's freeware and free distribution.
A very usefull tool. Just place a comment with your e-mail, or send an e-mail to:

itamar@facil.com

Regards,
Itamar
0
 
LVL 10

Expert Comment

by:viktornet
ID: 1338829
Hello spat! Whould you please grade Itamars' great answer so we can remove some unnecessary Qs from this pile ;->

//Vik
0
 
LVL 4

Expert Comment

by:itamar
ID: 1338830
I would apreciate too ;)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Virtualstringtree carsh after invalidate for while 5 86
Delphi cmd execution 6 56
Delphi and Access based Enumeration 9 47
Firemonkey DbLookupComboBox equivalent ? 2 36
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…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

920 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

14 Experts available now in Live!

Get 1:1 Help Now