Description
In this example I show how to get the CD-ROM's Serial Number
Code
SerialNumber.cpp
#include <vcl.h>
#pragma hdrstop
#include "SerialNumber.h"
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//----------------------------------------------------------------------
unsigned long Get_SerialNumber(char* RootPathName)
{
unsigned long SerialNumber;
GetVolumeInformation(RootPathName, NULL, 0, &SerialNumber,
NULL, NULL, NULL, 0);
return SerialNumber;
}
//----------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
char* RootPathName = "D:\\";
Label1->Caption = "Root Path Name " + String(RootPathName)
+ "\nSerialNumber "
+ String(Get_SerialNumber(RootPathName));
}
//----------------------------------------------------------------------
Copyright © 1997-2002 Rodolfo A. Frino. All rights reserved.