Package.GetAppInstallerInfo 方法

定義

傳回 .appinstaller XML 檔案位置。 當您需要擷取應用程式的 .appinstaller XML 檔案位置時,請使用這個方法。 例如,如果您的應用程式需要將其相關聯的 .appinstaller 檔案共用 URI,這會很有用。 您可以選擇性地將引數新增至 URI。

public:
 virtual AppInstallerInfo ^ GetAppInstallerInfo() = GetAppInstallerInfo;
AppInstallerInfo GetAppInstallerInfo();
public AppInstallerInfo GetAppInstallerInfo();
function getAppInstallerInfo()
Public Function GetAppInstallerInfo () As AppInstallerInfo

傳回

.appinstaller XML 檔案位置。

Windows 需求

裝置系列
Windows 10, version 1809 (已於 10.0.17763.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v7.0 引進)

範例

下列範例會產生具有引數的 .appinstaller URI,並建立電子郵件以將 URI 傳送給其他使用者。 在此範例中 ComposeEmailAsync ,系統會假設方法定義于其他地方。

AppInstallerInfo info = Windows.ApplicationModel.Package.Current.GetAppInstallerInfo();
if (info != null)
{
    // Uri that was used to install the app.
    // Example: http://contoso/connect4.appinstaller.
    Uri appInstallerUri = info.Uri;

    // Create the inner URI which uses a protocol handled by your app, passing any arguments needed in it 
    UriBuilder innerUriBuilder = new UriBuilder("my-app-protocol:");
    innerUriBuilder.Query = "difficulty=hard&highscore=9000";

    // Create outer URI builder for ms-appinstaller initializer link.
    UriBuilder outerUriBuilder = new UriBuilder("ms-appinstaller:");
    outerUriBuilder.Query =
        $"source={Uri.EscapeDataString(appInstallerUri.ToString())}&activationUri={Uri.EscapeDataString(innerUriBuilder.ToString())}";

    await ComposeEmailAsync(/* To */ colleagueEmail, /* Subject */ "Beat my high score!",
        /* Body */ outerUriBuilder.ToString());
}

備註

如果您想要取得與目前應用程式相關聯的 .appinstaller 檔案 URI,以便與使用者共用 URI,請使用此方法。 如果沒有應用程式的使用者按一下 URI,則會透過應用程式的安裝程式進行。 如果已經有應用程式的使用者按一下 URI,則會視需要更新應用程式,然後隨即開啟。

您可以選擇性地將引數新增至 URI。 在此情況下,行為與上述行為相同,但應用程式可以在開啟時使用引數。 引數必須使用應用程式支援的通訊協定。 如需詳細資訊,請參閱 處理 URI 啟用

適用於

另請參閱