Share via


IUpdateServer.GetRootUpdateCategories()

Retrieves a collection of the top-level categories on the WSUS server.

public UpdateCategoryCollection GetRootUpdateCategories();
Public Function GetRootUpdateCategories() As UpdateCategoryCollection
Implements IUpdateServer.GetRootUpdateCategories

Parameters

This method has no parameters.

Return Values

An UpdateCategoryCollection collection of the top-level categories on the WSUS server.

Remarks

A category can represent a company, product family, or product. The root category is the company category. The company category can have one or more subcategories known as product family categories. Product family categories contain one or more product categories. To determine the category's type, use IUpdateCategory.Type. For example, the company category for Microsoft is Microsoft Corporation. The Microsoft Corporation category contains the Windows product family category, which in turn contains product categories, such as the Windows Server 2003 family and the Windows XP family.

Typically, you use this method to list the available product and product families for each company. The user can then select the products to which they want to subscribe. For details, see ISubscription.SetUpdateCategories.

To retrieve all new categories that were added during a given period, call IUpdateServer.GetUpdateCategories.

Example Code

The following example shows how to recursively retrieve all categories on the WSUS server. The server variable that is used in the example is an instance of IUpdateServer (for information on retrieving an IUpdateServer instance, see AdminProxy.GetUpdateServer).

   //Display all root categories and their subcategories.
   DisplayCategories(server.GetRootUpdateCategories());

. . .

static void DisplayCategories(UpdateCategoryCollection categories)
{
   foreach (IUpdateCategory category in categories)
   {
      switch (category.Type)
      {
         case UpdateCategoryType.Company:
            Console.WriteLine();
            break;
         case UpdateCategoryType.ProductFamily:
            Console.Write("  ");
            break;
         case UpdateCategoryType.Company:
            Console.Write("    ");
            break;
      }

      Console.WriteLine("{0}", category.Title);
      if (category.ProhibitSubcategories == false) //category does not have subcategories
      {
         DisplayCategories(category.GetSubcategories());
      }
   }
}

Requirements

Server Requires Windows Server 2003 or Windows 2000 Server SP4 and later.
Namespace

Defined in Microsoft.UpdateServices.Administration.

Assembly

Requires Microsoft.UpdateServices.Administration (in Microsoft.UpdateServices.Administration.dll).

.NET Framework

Requires .NET Framework 1.1.