Previous articles Article This article describes how to view update software and how to download and install updates.
Before downloading, you must first determine whether there are any updates, and then determine which updates to download. Of course, you can also download all updates (this time is similar to the XP pirated update Patch to avoid downloading and installing ).
The updatesearcherclass, isearchresult, updatedownloaderclass, and updateinstallerclass classes are involved.
Start the search at the download point using the instance of updatesearcherclass and put the search result in isearchresult.
An updatedownloaderclass object is instantiated and the search result is returned to the updatedownloaderclass instance object.
Call the download method of the instance to start downloading. This method is not an asynchronous method, so the following method will be executed until the download is complete.
Installation:
Instantiate an updateinstallerclass class, give the search result to the instance, and then call the install method to install it.
In the investigation, the machine environment is vista. When the automatic update of the system is enabled and downloaded, use your ownProgramAfter the update, the system's automatic update program will not respond.
ReferenceCode:
1 Public Void Updatedownload ()
2 {
3 Wuapilib. updatesearcherclass upsearch = New Wuapilib. updatesearcherclass ();
4
5 If (Upsearch. Online)
6 {
7 Wuapilib. isearchresult Ressearch = Upsearch. Search ( " Isinstalled = 0 " );
8
9 Wuapilib. updatedownloaderclass updownload = New Wuapilib. updatedownloaderclass ();
10 Wuapilib. updateinstallerclass upinstall = New Wuapilib. updateinstallerclass ();
11
12 Updownload. Updates = Ressearch. updates;
13
14 System. Windows. Forms. MessageBox. Show ( " Start download " );
15
16 If (Updownload. Updates. Count > 0 )
17 {
18Updownload. Download ();
19}
20
21 System. Windows. Forms. MessageBox. Show ( " Start install " );
22
23 Upinstall. Updates = Updownload. updates;
24
25 If (Upinstall. Updates. Count > 0 )
26 {
27Upinstall. Install ();
28}
29
30 System. Windows. Forms. MessageBox. Show ( " Install OK " );
31 }
32 }