Solved

Hard disk information

Posted on 2002-03-08
1
406 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

760 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

20 Experts available now in Live!

Get 1:1 Help Now