Bearbeiten

Freigeben über


IUpdateDownloaderEx::BeginDownload2 method (wuapi.h)

Important

Some information relates to a prerelease product which may be substantially modified before it's commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Starts an asynchronous download of the content files that are associated with the updates.

Syntax

HRESULT BeginDownload2(
  DownloadType downloadType,
  IUnknown     *onProgressChanged,
  IUnknown     *onCompleted,
  VARIANT      state,
  IDownloadJob **retval
);

Parameters

downloadType

A value from the DownloadType specifying the type of download to perform, full download or downloading only the update bootstrapper.

Note

Attempting to download the update bootstrapper for an update that does not contain one will fail with the error code WU_E_NOT_SUPPORTED.

onProgressChanged

An IDownloadProgressChangedCallback interface that is called periodically for download progress changes before download is complete.

onCompleted

An IDownloadCompletedCallback interface that is called when an asynchronous download operation is complete.

state

The caller-specific state that the AsyncState property of the IDownloadJob interface returns. A caller may use this parameter to attach a value to the download job object. This allows the caller to retrieve custom information about that download job object at a later time.

Note

  The AsyncState property of the IDownloadJob interface can be retrieved, but it cannot be set. This does not prevent the caller from changing the contents of the object already set to the AsyncState property of the IDownloadJob interface. In other words, if the AsyncState property contains a number, the number cannot be changed. But, if the AsyncState property contains a safe array or an object, the contents of the safe array or the object can be changed at will. The value is released when the caller releases IDownloadJob by calling IUpdateDownloader::EndDownload.

retval

An IDownloadJob interface that contains the properties and methods that are available to a download operation that has started.

Return value

An HRESULT including one of the following values:

Value Description
S_OK Success.
WU_E_INVALID_OPERATION The computer cannot access the update site.
WU_E_NO_UPDATE The Windows Update Agent (WUA) does not have updates in the collection.
WU_E_NOT_INITIALIZED The Windows Update Agent (WUA) is not initialized.
WU_E_NOT_SUPPORTED The update bootstrapper download was attempted on an update that doesn't contain one.

Remarks

As an alternative to implementing the IDownloadProgressChangedCallback interface, you can use a script to implement a callback routine of any identifier with DISPID 0 on an automation object. The type of the onProgressChanged parameter is IUnknown.

As an alternative to implementing the IDownloadCompletedCallback interface, you can use a script to implement a callback routine of any identifier with DISPID 0 on an automation object. The type of the onCompleted parameter is IUnknown.

This method returns WU_E_INVALID_OPERATION if the object that is implementing the interface is locked down.

This method returns WU_E_NO_UPDATE if the Updates property of the IUpdateDownloader interface is not set. This method also returns WU_E_NO_UPDATE if the Updates property is set to an empty collection.

This method returns SUS_E_NOT_INITIALIZED if the download job contains no updates.

When you use any asynchronous WUA API in your app, you might need to implement a time-out mechanism. For more info about how to perform asynchronous WUA operations, see Guidelines for Asynchronous WUA Operations.

Requirements

Requirement Value
Minimum supported client Windows 11 Build 26100
Header wuapi.h