Solved

CD ID Code

Posted on 1998-09-06
3
155 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

776 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