Working with Managed Volumes

When you are creating a custom application, you may want to get information about managed volumes that are on the home server. Using the API for Windows Home Server, you can write code that retrieves information about managed volumes on the server.

Managed Volume Properties

An individual managed volume is represented as a IVolumeInfo object, and it has the following read-only properties:

  • Used space

  • Size

  • Path

Managed Volume Example

Step 1: Create an instance of WHSInfoClass

As with most API objects for Windows Home Server, retrieving information about managed volumes begins by creating an instance of the WHSInfoClass, as follows:

WHSInfoClass pInfo = new WHSInfoClass();
Dim pInfo As New WHSInfoClass()

Step 2: Call the GetVolumeInfo() method

The GetVolumeInfo method is the WHSInfoClass method that you use to get information about managed volumes on the home server. It returns an array of IVolumeInfo objects that represent all of the managed volumes on the home server:

Array volumes = pInfo.GetVolumeInfo();
Dim volumes As Array = pInfo.GetVolumeInfo()

Step 3: Loop through the array

Because the GetVolumeInfo method returns an array of IVolumeInfo objects, you can loop through the entire array to get information about a particular instance of a managed volume:

foreach (IVolumeInfo pVolume in volumes) 
{
  Console.WriteLine("Size: {0}" + pVolume.Size);
  Console.WriteLine("Used Space: {0}" + pVolume.UsedSpace);
  Console.WriteLine("Path: {0}" + pVolume.Path);
}
Dim pVolume As IVolumeInfo
For Each pVolume In volumes
    Console.WriteLine("Size: {0}" + pVolume.Size)
    Console.WriteLine("Used Space: {0}" + pVolume.UsedSpace)
    Console.WriteLine("Path: {0}" + pVolume.Path)
Next pVolume

You can use this same approach whenever you need to work with managed volumes through the API for Windows Home Server.

See Also

Reference

IVolumeInfo
WHSInfoClass

Concepts

Extending Windows Home Server
Working with WHSInfoClass
Working with Client Computers
Working with Users
Working with Application Folders
Working with Hard Disks
Working with Notifications
Working with Backups

Other Resources

Working with Shared Folders