共用方式為


XPackageUninstallPackage

Uninstalls a given package.

Syntax


bool XPackageUninstallPackage(
    const char* packageIdentifier) 
noexcept;

Parameters

packageIdentifier   _In_z_
Type: char*

A string that uniquely identifies the installed package on the disk. For more information about package identifiers, see Manage and license downloadable content (DLC).

Return value

Type: bool

Bool tells whether package was uninstalled successfully or not.

Remarks

Note

This function isn't safe to call on a time-sensitive thread. For more information, see Time-sensitive threads.

XPackageUninstallPackage uninstalls the given package. The package identifier provided will have been returned from XPackageEnumeratePackages or another API that returns a package identifier. XPackageUninstallPackage returns true if the package was uninstalled or false if the package could not be uninstalled.

Reasons for a package failing to uninstall include:

  • The package is in use. For example, it is a DLC package the game currently has mounted.
  • The game is running on an xCloud server. Package installation and removal is the responsibility of the server environment.

In the following example, XPackageUninstallPackage is used to uninstall a package to free up space on disk for user.

bool UninstallDlcToReclaimDiskSpace(const char_t* packageIdentifier) 
{
return XPackageUninstallPackage(packageIdentifier);
} 

Requirements

Header: XPackage.h

Library: xgameruntime.lib

Supported platforms: Windows, Xbox One family consoles and Xbox Series consoles

See also

XPackage
Streaming Installation and Intelligent Delivery