Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to read the hard disk serial number and volume label. Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
Read the hard disk serial number and volume label 09-May-04
Category
Files Operation
Language
CBuilder All Versions
Views
546
User Rating
10
# Votes
2
Replies
0
Publisher:
Darley, F. Joe
Reference URL:
			1   
2   //This example get the give hard drive serial number and Volume label
3   
4   #include <vcl.h>
5   #pragma hdrstop
6   
7   #include "Unit1.h"
8   #include "dir.h"
9   #include "stdio.h"
10  
11  
12  //---------------------------------------------------------------------------
13  #pragma package(smart_init)
14  #pragma resource "*.dfm"
15  TForm1 *Form1;
16  //---------------------------------------------------------------------------
17  __fastcall TForm1::TForm1(TComponent* Owner)
18          : TForm(Owner)
19  {
20  }
21  AnsiString TForm1::GetHardDiskSerial(String  DriveChar){
22  
23  String RootPathName = DriveChar +":\\";
24  char VolumeNameBuffer[_MAX_PATH], FileSystemBuffer[_MAX_PATH];
25  DWORD VolumeSerialNumber, MaximumComponentLength, FileSystemFlags;
26  AnsiString SerialNumber;
27  
28   GetVolumeInformation(
29     RootPathName.c_str(),
30     VolumeNameBuffer,
31     sizeof(VolumeNameBuffer),
32     &VolumeSerialNumber,
33     &MaximumComponentLength,
34     &FileSystemFlags,
35     FileSystemBuffer,
36     sizeof(FileSystemBuffer) );
37  
38  int lo, hi;
39  char lob[8], hib[8];
40  
41  lo = VolumeSerialNumber & 0xFFFF;
42  hi = (VolumeSerialNumber >> 16) & 0xFFFF;
43  
44  sprintf(lob, "%04x", lo);
45  sprintf(hib, "%04x", hi);
46  
47  SerialNumber = UpperCase(AnsiString(hib)) + "-" +
48  UpperCase(AnsiString(lob));
49  
50   SerialNumber="Label="+ (AnsiString)VolumeNameBuffer+" Serial= 
51  "(AnsiString)SerialNumber;
52  
53  
54    return  SerialNumber;
55  
56  
57   }
58  
59  //---------------------------------------------------------------------------
60  
61  
62  void __fastcall TForm1::Button1Click(TObject *Sender)
63  {
64  ShowMessage(GetHardDiskSerial('c'));
65  }
66  //---------------------------------------------------------------------------
67  


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC