n3rd
n3rd

Reputation: 6089

How can I retrieve information about disk volumes?

I was looking around for a tool to monitor the status of my software raid under Windows 2003 Server, but couldn't find anything suitable (i.e. not grossly oversized or needlessly complicated). So I decided to just do it myself, it's nothing spectacularly difficult.

So how can I retrieve the status of the volumes programmatically? It's been a while since I fiddled with the Windows API and I couldn't find anything right off the bat using Google. I know I can use diskpart /s and parse its output, but that gets messy fairly quickly (although it does have some advantages).

Any pointers into the right direction are highly appreciated :)

Upvotes: 1

Views: 1561

Answers (4)

n3rd
n3rd

Reputation: 6089

The Win32 API is the (apparently only) way to go here, Virtual Disk Service is the magic word.

Here is a good example in C++ that will get you started. The number of different COM interfaces was pretty confusing for me at first, but the How Virtual Disk Service Works article was of great help getting the big picture.

It's actually pretty easy. Despite never having done any serious C++ coding and never having even touched COM before, I was still able to get the basic functionality to work in a few hours.

Upvotes: 2

Mark Simpson
Mark Simpson

Reputation: 23365

I don't know if RAID stuff will complicate matters, but I've used System.IO.DriveInfo.GetDrives() before and that's worked fine for my needs.

Upvotes: 0

Shiraz Bhaiji
Shiraz Bhaiji

Reputation: 65361

You could try monitoring the Event log for RAID events.

Upvotes: 0

Kenan E. K.
Kenan E. K.

Reputation: 14111

Did you check WMI?

You can take a look here for a demo.

Upvotes: 0

Related Questions