programming4us
programming4us
ENTERPRISE

Windows 7 : Interacting with the Built-In Security Features - WORKING WITH AUTOMATIC UPDATES (part 2)

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

3. Writing the Update Code

Once you know whether the user's system is healthy from an update check and download perspective, you need to know which updates the user has actually installed. For example, you might worry that your application won't work properly without the daylight saving time and time zone updates found in the Knowledge Base article at http://support.microsoft.com/kb/2158563. Using the technique shown in Listing 2, you can obtain the complete list of updates and search it for the appropriate update.

Example 2. Obtaining a list of installed updates
private void btnUpdates_Click(object sender, EventArgs e)
{
// Clear the list box.
lstResults.Items.Clear();

// Create the Microsoft Update Searcher (MUS) type.
Type MUStype = Type.GetTypeFromProgID("Microsoft.Update.Searcher");

// Use the MUS type to create a searcher object.
dynamic Searcher = Activator.CreateInstance(MUStype);

// Access the entire history.
dynamic Updates =
Searcher.QueryHistory(0, Searcher.GetTotalHistoryCount());

// Check each update in the history in turn.
foreach (dynamic Update in Updates)
{
// Display only the successful updates.
if (Update.ResultCode == 2)
{
// Display the update information.

lstResults.Items.Add("Title: " + Update.Title);
lstResults.Items.Add("Description: " + Update.Description);
lstResults.Items.Add("Date (GMT): " + Update.Date);
lstResults.Items.Add("Installation Method: " +
Update.ClientApplicationID);

// Add a blank line.
lstResults.Items.Add("");
}
}
}

The code begins by clearing the previous results from the list box and creating a Type, MUStype, based on Microsoft.Update.Searcher. The code then creates the Search object using Activator.CreateInstance() with MUStype as an argument.

The Searcher object actually has access to a number of methods for querying the update database. The example uses the simplest of these techniques, QueryHistory(). You supply the starting record and number of records to return as inputs. The other methods are documented at http://msdn.microsoft.com/library/aa386530.aspx.

The next step is determining which updates to check. One of the most important properties for developers is the ResultCode. The example looks for updates that succeeded. A result code can have any of the following values:

  • 2: The update succeeded.

  • 4: The update failed for some reason other than that the user or system aborted it.

  • 5: The user or the system aborted the update. An update is aborted either manually or when the system detects an error in the update code or conditions.

  • Other: There could be other update codes that aren't listed. A third-party vendor could provide an update code for a partial update or a pending update. In most cases, you aren't concerned about these alternate conditions and need to know only whether the update succeeded, failed, or aborted.

    Figure 3. It's possible to search the update database for a particular update.
The output information also includes an update title, a description of what the update does, the date the user installed the update, and the technique used to install the update. Figure 3 shows typical output from this part of the example.
Other  
  •  Windows 8 Architecture from a Developer’s Point of View : Understanding Windows Runtime (part 5) - What’s not in Windows Runtime
  •  Windows 8 Architecture from a Developer’s Point of View : Understanding Windows Runtime (part 4) - Language Projections
  •  Windows 8 Architecture from a Developer’s Point of View : Understanding Windows Runtime (part 3) - Metadata in Windows Runtime - Namespaces
  •  Windows 8 Architecture from a Developer’s Point of View : Understanding Windows Runtime (part 2) - Metadata in Windows Runtime - Metadata Format
  •  Windows 8 Architecture from a Developer’s Point of View : Understanding Windows Runtime (part 1) - Windows Runtime Architecture Overview
  •  Windows 8 Architecture from a Developer’s Point of View : Windows 8 Development Architecture
  •  Windows 7 : Programming KMDF Hardware Driver - Mapping Resources - Code to Map Resources
  •  Windows 7 : Programming KMDF Hardware Driver - Handling Interrupts (part 2) - Deferred Processing for Interrupts
  •  Windows 7 : Programming KMDF Hardware Driver - Handling Interrupts (part 1) - Code for EvtInterruptIsr Callback
  •  Windows 7 : Programming KMDF Hardware Driver - Support Device Interrupts (part 2) - Post-Interrupt Enable and Pre-Interrupt Disable Processing
  •  
    Top 10
    Free Mobile And Desktop Apps For Accessing Restricted Websites
    MASERATI QUATTROPORTE; DIESEL : Lure of Italian limos
    TOYOTA CAMRY 2; 2.5 : Camry now more comely
    KIA SORENTO 2.2CRDi : Fuel-sipping slugger
    How To Setup, Password Protect & Encrypt Wireless Internet Connection
    Emulate And Run iPad Apps On Windows, Mac OS X & Linux With iPadian
    Backup & Restore Game Progress From Any Game With SaveGameProgress
    Generate A Facebook Timeline Cover Using A Free App
    New App for Women ‘Remix’ Offers Fashion Advice & Style Tips
    SG50 Ferrari F12berlinetta : Prancing Horse for Lion City's 50th
    - Messages forwarded by Outlook rule go nowhere
    - Create and Deploy Windows 7 Image
    - How do I check to see if my exchange 2003 is an open relay? (not using a open relay tester tool online, but on the console)
    - Creating and using an unencrypted cookie in ASP.NET
    - Directories
    - Poor Performance on Sharepoint 2010 Server
    - SBS 2008 ~ The e-mail alias already exists...
    - Public to Private IP - DNS Changes
    - Send Email from Winform application
    - How to create a .mdb file from ms sql server database.......
    programming4us programming4us
    programming4us
     
     
    programming4us