Working with Client Computers

When you are creating a custom application for Windows Home Server, you may want to get information about client computers (also called "home computers") that are on the Windows Home Server network. By using the API for Windows Home Server, you can write code that retrieves information about client computers and uses it in your custom application.

Client Computer Properties

An individual client computer is represented as a IComputerInfo object, and it has the following read-only properties:

  • Name

  • Text description

  • Operating system

  • IP address

  • Online status (online or offline)

Client Computer Example

Step 1: Create an instance of WHSInfoClass

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

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

Step 2: Call the GetClientComputerInfo() method

The GetClientComputerInfo method is the WHSInfoClass method that you use to get information about client computers. It returns an array of IComputerInfo objects that represent all client computers on the network:

Array comps = pInfo.GetClientComputerInfo();
Dim comps As Array = pInfo.GetClientComputerInfo()

Step 3: Loop through the array

Because the GetClientComputerInfo method returns an array of IComputerInfo objects, you can loop through the array to get information about client computers:

foreach (IComputerInfo pComp in comps) 
{
  Console.WriteLine("Computer: " + pComp.ComputerName);
  Console.WriteLine("Description: " + pComp.Description);
  Console.WriteLine("IPAddress: " + pComp.IPAddress);
  Console.WriteLine("IsOnline: " + pComp.IsOnline);
  Console.WriteLine("OS: Windows Version " + pComp.OSMajorNumber + "." + pComp.OSMinorNumber);
}
Dim pComp As IComputerInfo
For Each pComp In comps
    Console.WriteLine("Computer: " + pComp.ComputerName)
    Console.WriteLine("Description: " + pComp.Description)
    Console.WriteLine("IPAddress: " + pComp.IPAddress)
    Console.WriteLine("IsOnline: " + pComp.IsOnline)
    Console.WriteLine("OS: Windows Version" + pComp.OSMajorNumber + "." + pComp.OSMinorNumber)
Next pComp

You can use this same approach whenever you are working with client computers through the API for Windows Home Server.

Windows Home Server SDK and Client Computers

You should use the Windows Home Server SDK only on the home server. Using it on client computers is not supported. However, you can obtain information about the relationship of a client computer to Windows Home Server through registry entries on the client computer.

To determine if the Windows Home Server Connector software is installed on the client computer, check for the presence of the string value Version in the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Home Server registry key. You must check for the presence of this value and not just for the presence of the key, because the registry key may be left even after the Connector software has been uninstalled.

If you want to change the behavior of your application based on the status of Backup for the client computer, examine the value BackupEnabled in the HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Home Server registry key. If the value is 1, the client computer is backed up by Windows Home Server. If the value is anything other than 1, the client computer is not backed up. You should check to see if the Connector software is installed before checking to see if the client computer is being backed up.

See Also

Reference

IComputerInfo
WHSInfoClass

Concepts

Extending Windows Home Server
Working with WHSInfoClass
Working with Application Folders
Working with Managed Volumes
Working with Hard Disks
Working with Notifications
Working with Backups

Other Resources

Working with Shared Folders