MddBootstrapInitialize2 function (mddbootstrap.h)

Initializes the calling process to use the version of the Windows App SDK framework package that best matches the specified criteria, with options. This function is intended to be used by desktop apps that are either packaged with external location, or unpackaged.

MddBootstrapInitialize2 offers usability and troubleshooting improvements over MddBootstrapInitialize.

Also see Constants.

Syntax

HRESULT MddBootstrapInitialize2(
  UINT32                        majorMinorVersion,
  PCWSTR                        versionTag,
  PACKAGE_VERSION               minVersion,
  MddBootstrapInitializeOptions options
);

Parameters

majorMinorVersion

Type: UINT32

The major and minor version of the Windows App SDK product to load (for example, 1.2). This is an exact major and minor version to match on; not a minimum.

majorMinorVersion is encoded as 0xMMMMNNNN, where M = Major and N = Minor (for example, version 1.2 is encoded as 0x00010002).

versionTag

Type: PCWSTR

The version tag of the Windows App SDK framework package to load (if any). For example, "prerelease".

minVersion

Type: PACKAGE_VERSION

The minimum version of the Windows App SDK runtime package (that also matches majorMinorVersion) to use.

This version (for example, 0.319.455) is different from the Windows App SDK release version (for example, 1.0.2) and product version (for example, 1.0).

The Windows App SDK runtime version values can be obtained from the C++ header WindowsAppSDK-VersionInfo.h, see Example for more details.

options

Type: MddBootstrapInitializeOptions

Options for bootstrapper initialization.

Return value

Type: HRESULT

If the function succeeds it returns ERROR_SUCCESS. Otherwise, the function returns an error code.

Remarks

Any errors are logged to the EventLog's Application channel.

You can call this function multiple times provided that the parameters are compatible. The first call does the work to resolve a Framework package; subsequent calls are a no-op provided that the parameters are compatible with the Framework package resolved by the first call. If subsequent calls' parameters are not compatible, then the API fails and returns an error.

This function finds a Windows App SDK framework package that meets the specified criteria and makes the package available for use by the current process. If multiple packages meet the criteria, this function selects the best candidate.

This function must be called at startup before calling any other Windows App SDK APIs to ensure the bootstrapper component can properly initialize the Windows App SDK and add the runtime reference to the framework package.

This function also initializes the Dynamic Dependency Lifetime Manager (DDLM). The DDLM provides infrastructure to prevent the operating system (OS) from servicing the Windows App SDK framework package while it's being used by an unpackaged app.

Also see Use the Windows App SDK runtime for apps packaged with external location or unpackaged.

Note

COM must be initialized for the current thread before you call this function.

Note

If in options you don't specify MddBootstrapInitializeOptions::MddBootstrapInitializeOptions_OnPackageIdentity_NOOP, then for this API to succeed in an app that's either packaged with external location or unpackaged, it's necessary for the Windows App SDK packages to be installed on the device (see Tutorial: Use the bootstrapper API in an app packaged with external location or unpackaged that uses the Windows App SDK).

Example

#include <WindowsAppSDK-VersionInfo.h>
#include <MddBootstrap.h>
// ...

if (FAILED(MddBootstrapInitialize(Microsoft::WindowsAppSDK::Release::MajorMinor, Microsoft::WindowsAppSDK::Release::VersionTag, Microsoft::WindowsAppSDK::Runtime::UInt64))) {
    throw std::exception("Error in Bootstrap initialization");
}
#include <WindowsAppSDK-VersionInfo.h>
#include <MddBootstrap.h>
// ...

HRESULT hr = MddBootstrapInitialize(WINDOWSAPPSDK_RELEASE_MAJORMINOR, WINDOWSAPPSDK_RELEASE_VERSION_TAG_W, WINDOWSAPPSDK_RUNTIME_VERSION_UINT64);
if (FAILED(hr))
{
    wprintf(L"Error 0x%X in Bootstrap initialization\n", hr);
}

Requirements

Requirement Value
Minimum supported client Windows 10, version 1809 (with Windows App SDK 1.0 or later)
Header mddbootstrap.h
Library Microsoft.WindowsAppRuntime.Bootstrap.lib
DLL Microsoft.WindowsAppRuntime.Bootstrap.dll

See also