[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1364
  • Last Modified:

List all physical hard drives showing manufacturer, model etc

Hello Experts,

Can someone supply me with a unit for Delphi 5 with a function and procedure to return as much  as possible of  the information listed below, for each physical hard drive?

NOTES
1)  Need only work on Win2K upwards
2)  Must work on both IDE and SATA drives
3)  Since some external USB hard drives show up in Disk Management as a Fixed drive,  it would be nice to get info on their internal hard drives as well. However, due to USB limitations, I suspect it won't be possible. In that case internal hard drives only would be fine.

Suggesteds:
Function    GetMaxHardDriveCount: integer
Procedure GetPhysicalDriveInfo(DriveNum, var [the return variables]: boolean

INFO TO BE RETURNED
1) The total number of fixed physical hard drives (USB if possible)
2) The drive manufacturers name
3) The drives model number
4) The drives firmware revision                      [desirable but not essential]
5) The interface type (e.g. AT, SATA, USB)    [desirable but not essential]
6) The size of the drive
7) The unused space on the drive (or alternatively  used space)

Any appropriate comments in the code would be appreciated.

Thanks for your help!
0
WinRat
Asked:
WinRat
  • 10
  • 9
2 Solutions
 
MerijnBSr. Software EngineerCommented:
You'll need http://www.mitec.cz/msics.html. Unfortunately it isn't sold anymore. I have a license which permits me to make you a DLL to do this though (can't give you sources). Will that do?
0
 
WinRatAuthor Commented:
Hi MerijnB:

As a compulsive downloader I already had most of MiTec's free stuff plus the component suite demo: System Information X (V10.6). I ran it and was impressed with all the information!
The Storage/Physical Devices enumeration has most of the info I am looking for: it includes hard drives (internal & external), USB Flash Drives and CD/DVD Drives.

By the way the demo indicates the SATA drive in my PC is on a ATA bus. Not sure if that is correct. Maybe its the way SATA is implemented on the motherboard.
In any event it would be nice if the bus type did indicate SATA for those drives.

There is more information than what I asked for, but since its already there in the component, maybe you wouldn't mind adding some of it to the information I already requested. You will be getting MaxPoints anyway to make it worthwhile!

So, if you could make a DLL which would export the function and procedure I asked for that would be OK with me. It meets my requirement that any program I write can have access to one or all drives info. Since there will be quite a lot of info to be returned it might be better to have some structure defined to hold it

I have never called a function in a DLL before so can you give me a brief explanation or supply a simple demo on how to do so.

DRIVE INFO REQUIRED
Looking at the detailed info the component supplies for each drive this is what I would like:
Make/Model           - looks like only the model is given
Revision
Serial number
Bus Type
Temperature          - this is really handy to have!
Capacity
Free space           - Not provided in the DEMO - can obtain another way?
SMART (supported)
SMART (active)
[Partition drive letter(s)]

Note: Since the DEMO also shows the drive letters for each physical drive's partition(s) can you return a string with the letters concatenated, or an array of char?

If you can do all of this I will be over the moon. But even if only most of it I will still be happy!

Mike

0
 
MerijnBSr. Software EngineerCommented:
I will take a look at it, might be over the weekend though.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
WinRatAuthor Commented:
MerijnB:

Thanks! I wish everyone was as quick to respond as you!
Over the weekend will be fine, even early next week - no desperate hurry and doesn't look like anyone else wants this one.

0
 
WinRatAuthor Commented:
PS FYI: I found this notice at the bottom of the component webpage http://www.mitec.cz/msi.htm
Maybe it is available again?

Ordering

MSICS is used for developing a commercial product and due to market ability of this product selling of MSICS has been stopped for one year (till 1.5.2007).
However it will be still developed and all current customers will receive updates for free in the future.
0
 
MerijnBSr. Software EngineerCommented:
You can email him, it's definitely worth the cost.
0
 
WinRatAuthor Commented:
MerijnB:
Cost is 110 Euro's, and at 12.8 of our currency (Rands) to the Euro, way out of my reach!
But I emailed him anyway out of interest and will let you know his reply.
0
 
MerijnBSr. Software EngineerCommented:
A file has been uploaded to EE-Stuff.com

Uploaded by : MerijnB
Filename : EE_HDDInformation.zip
Size : 620,005 bytes
Comment : DLL, wrapper and sample application to get several HDD information

You can download this file from https://filedb.experts-exchange.com/incoming/ee-stuff/7529-EE_HDDInformation.zip

If other files are available for this question, then they can be accessed from https://filedb.experts-exchange.com/incoming/ee-stuff/7540-EE_HDDInformation.ziphttps://filedb.experts-exchange.com/incoming/ee-stuff/7529-EE_HDDInformation.zip
0
 
WinRatAuthor Commented:
Hi MerijnB,

Thanks so much for the code. I have downloaded it but have been a bit too busy at work to try it yet. Will let you know soon.

0
 
WinRatAuthor Commented:
Hi MerijnB,

Sorry delay - was too tired last night.
Firstly, I heard from the MiTec guy. The info I sent you was old and should have been changed. He will fix the website. So still not available.

Regarding your DLL & example prog unfortunately there are some problems.

When I ran your demo EXE on my home PC it only shows drive indexes 6 & 7 in the memo.

I loaded your code into D5 but to get it to compile had to add some pointer type definitions that you used in HDDInformation.pas and also remove Variants from main.pas.
 type
   PBoolean = ^Boolean;                
   PByte    = ^Byte;                  

When I ran the re-compiled version in Delphi it crashed after drive index 0 (which was my flash drive) with an EInvalidPointer exception as it began processing drive index 1 (i.e. GetPhysicalDisk(i, PhysicalDisk).
I tried stand-alone and the same thing happened.

The odd thing is that the demo EXE you supplied doesn't crash with an error, but only shows two of the drives. The only source differences are what I mentioned. Must be something to do with the compiler you used.

I wonder if this problem has something to do with trying to get info for non-hard drives where it doesn't apply (e.g. CD drives)

I also noticed that the drive indexes don't correspond to the actual Physical Drive Numbers as indicated in Disk Management. Could this be fixed?
    Index 0 is actually Hard  Drive 3   (flash)
    Index 6 is actually Hard  Drive 1   (fixed)
    Index 7 is actually Hard  Drive 2   (fixed)

The PhysicalDiskCount of 7 corresponded to the total number of drives (8) in my system. I have:
 0,1,2 = fixed hard drives
 3        =  flash drive
 The other 4 drives are a DVD Drive and three Virtual CD drives.

It would also be very useful if you could also add two properties that I had asked for:
Bus Type & Capacity.
That would help me differentiate between the drives (I am mainly interested in Fixed and Removable hard drives).

I hope you still have the time to look into these problems?
Thanks for the help so far.

 
0
 
MerijnBSr. Software EngineerCommented:
On the bugs / crashses:

As you've concluded yourself, it has to do with the compiler, since the compiled version works find (I've compiled with Delphi 2006 btw). I'll whip up an old Delphi version, but that will not be before monday.

> I also noticed that the drive indexes don't correspond to the actual Physical Drive Numbers as indicated in Disk Management. Could this be fixed?
Don't think so, I have no information on the correspondence between the two.

> It would also be very useful if you could also add two properties that I had asked for:
> Bus Type & Capacity.
> That would help me differentiate between the drives (I am mainly interested in Fixed and Removable hard drives).

I've passed all information I got from MSIC, so if it's not there now, I don't have it. I do pass information about whether it's a fixed/removable of other drive though, It's in the mediatype property.
0
 
WinRatAuthor Commented:
Hi MerijnB:

After reading your post I thought that if the compiled EXE in the ZIP you posted worked on your system - it should work on mine.

I only ran it once, it looked like it didn't work, so I left it as I was more interested in getting the source to compile in D5.

Well, I ran it again now, and I was too hasty! It actually does work. It merely looked like only part of the drive info was there. This is what I saw:
------------------------------------------
Drives:

Index: 6
SerialNumber: L40P9P8H
Model: 6L160P0
Vendor: Maxtor
Revision: BAH41G10
Drives:

Index: 7
SerialNumber: WD-WXE307183592
Model: WD1600BEAE-00UWT0
Vendor: WDC
Revision: 01.04A01
Drives:
------------------------------------------
I thought that that was all the info there was because the memo didn't have any scroll bars showing and scrolling with the mouse didn't show more. Anyway, when I used the keyboard to scroll up there the rest of it was - voila! Sorry about that, a hasty assumption on my part.

Of course that leaves the compile problem which I look forward to you sorting out for D5 this week.

(this has raised another interesting question for me now: how do you get mouse scrolling support into D5 listboxes and memos!)

It is strange that no "Drives:"  info was returned for my three hard drives - only for the CDROM's and flash drives as follows:
------------------------------------------
Index: 0
SerialNumber:
Model: 2.0
Vendor: KingstonDataTraveler
Revision: PMAPPMAP123
Drives: H
------------------------------------------

Thanks for your efforts so far!

0
 
MerijnBSr. Software EngineerCommented:
Sorry for the delay, I've been somewhat busy. I'll upload a new version in a moment, works with D5, it also contains an executable compiled with D5.
0
 
MerijnBSr. Software EngineerCommented:
A file has been uploaded to EE-Stuff.com

Uploaded by : MerijnB
Filename : EE_HDDInformation.zip
Size : 650,888 bytes
Comment : New version, now works with D5

You can download this file from https://filedb.experts-exchange.com/incoming/ee-stuff/7540-EE_HDDInformation.zip

If other files are available for this question, then they can be accessed from https://filedb.experts-exchange.com/incoming/ee-stuff/7540-EE_HDDInformation.ziphttps://filedb.experts-exchange.com/incoming/ee-stuff/7529-EE_HDDInformation.zip
0
 
WinRatAuthor Commented:
Hi MerijnB:

Sorry haven't got good news for you!
Your new EXE worked fine - all drives and info correctly displayed.

But still unable to get your source code & DLL to work.

Using the new (D5) code, it now compiles OK and loops through all drives - but no values are returned from PhysicalDisk. You get the text output correctly in the memo but no values. I set a breakpoint in the loop but definitely all values are null. I tried both the previous and latest DLL's (is there a difference, the sizes differ?) but also made no difference.

So not being able to do anything else with it, I went back to the previous D7 code. In fact there is almost no difference between the D5 & 7 versions of both units except for the missing pointer type definitions and the extra code for the media type strings.

As before, the D7 version would not compile under D5 so I tried it in D6. This compiled and ran and processed the first drive OK but when it got to   GetPhysicalDisk(i, PhysicalDisk) for the 2nd one the TInvalidPointer exception was thrown and it exited through the finally block.

So there it is. I have no idea what is going on. Must be something to do with the DLL?

I can't yet say my question has been answered. The latest EXE works but I need to be able to compile a working version in D6 at least to show I can use the solution in my own programs.

Do you still want to continue with this questions? Or do you think you have spent long enough om it? If so I will give you half the points if that's fair?
 
Thanks!
0
 
MerijnBSr. Software EngineerCommented:
Did the executable compiled with D5 work?
0
 
WinRatAuthor Commented:
@MerijnB:

>Did the executable compiled with D5 work?
>> ... The latest EXE works but I need to be able to compile a working version in D6>>  at least to show I can use the solution in my own programs.

As indicated the latest source code you posted doesn't compile to a working version in either D5 or D6. However the latest EXE you posted in the ZIP does work! That's the puzzling thing.

If you still want to work on this, time is running out. I have posted to close this questions as my premium membership expires on the 17th and EE has indicated I must make sure all my questions are closed or dealt with by then. i will not be able to see solutions after that.

0
 
MerijnBSr. Software EngineerCommented:
What kind of error do you get when you compile in D5 or D6?
I'd like to provide you a working solution on this question even after your EE membeship expires. You can mail me at merijnb@xs4all.nl
0
 
WinRatAuthor Commented:
@MerijnB:

As indicated in earlier comment the last code you posted compiles fine in D5 to an EXE.
The various fields are displayed - it just doesn't return any values for each one!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Using the new (D5) code, it now compiles OK and loops through all drives - but no values are returned from PhysicalDisk. You get the text output correctly in the memo but no values. I set a breakpoint in the loop but definitely all values are null. I tried both the previous and latest DLL's (is there a difference, the sizes differ?) but also made no difference.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I'm not sure how to debug this. \Why should your EXE work fine but not my EXE compiled from the same code. One possible explanation: are you quite sure the code you sent me is the same as the code you used to make the EXE!

Thanks for the offer to continue with solving this one!
 I will delete the question (my) tomorrow night (GMT+2) and will then contact you via your email address.


0
 
infokrtCommented:
Finally! This is what I've been searching for so long but is there a possibility to get volume size too?
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 10
  • 9
Tackle projects and never again get stuck behind a technical roadblock.
Join Now