Solved

Hard disk information

Posted on 2002-03-08
1
415 Views
Last Modified: 2010-04-05
Hi,

Does anybody know how to get disk information (hard drive) without having to add some third party component? Does Delphi itself provide such feature (something like "GetDiskInfo")? I have to get HD number...

Thanks in advance
0
Comment
Question by:binho
1 Comment
 
LVL 3

Accepted Solution

by:
tongalite earned 50 total points
ID: 6851267


Hi this will do what you want.
Have fun
T.

unit GetSer;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Label1: TLabel;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}
function GetDiskSerialNumber(Disk: char): string;
var
 VolumeSerialNumber,
 MaximumComponentLength,
 FileSystemFlags: DWORD;
 SerialNumber: string;
begin

 GetVolumeInformation(PChar(Disk + ':\'),
                      nil,
                      0,
                      @VolumeSerialNumber,
                      MaximumComponentLength,
                      FileSystemFlags,
                      nil,
                      0);
 SerialNumber := Format('%.4X-%.4X', [HiWord(VolumeSerialNumber), LoWord(VolumeSerialNumber)]);

 Result := SerialNumber;

end;

procedure TForm1.Button1Click(Sender: TObject);
begin
Label1.caption:=(GetDiskSerialNumber('C'));
 
end;

end.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
code issue 8 184
Delphi - replicating a form 8 92
error 1.1 400 Bad request idhttp delphi 18 204
How to open a new windows chrome resized and disabled the toolbar? 3 197
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

733 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