Share via


Using WSUS

The IUpdateServer interface is the main entry point for the WSUS API. To retrieve an IUpdateServer instance, call AdminProxy.GetUpdateServer. Then, set IUpdateServer.PreferredCulture to the locale in which you want WSUS to return strings.

The following example shows how to retrieve an instance of the IUpdateServer interface and to set the IUpdateServer.PreferredCulture property.

IUpdateServer server = AdminProxy.GetUpdateServer();
IUpdateServerConfiguration configuration = server.GetConfiguration();
System.Collections.Specialized.StringCollection supportedLanguages = configuration.SupportedUpdateLanguages;
String clientLanguageCode = System.Threading.Thread.CurrentThread.CurrentUICulture.Name; //is of the form, "en-US"

if (supportedLanguages.Contains(clientLanguageCode.ToLower()))
    server.PreferredCulture = clientLanguageCode;
else
{
    clientLanguageCode = System.Threading.Thread.CurrentThread.CurrentUICulture.Parent.Name; //is of the form, "en"
    if (supportedLanguages.Contains(clientLanguageCode.ToLower()))
        server.PreferredCulture = clientLanguageCode;
    else
        server.PreferredCulture = "en"; //default to English
}

After retrieving the IUpdateServer interface and setting the IUpdateServer.PreferredCulture property, you can use the WSUS API to perform the following tasks or other tasks:

For information on referencing the WSUS assembly, see Referencing the Update Services Assembly.