共用方式為


ProtocolActivatedEventArgs 類別

定義

啟用應用程式時提供資料,因為它是與 URI 配置名稱相關聯的應用程式。

JAVAscript 此類型會顯示為 WebUIProtocolActivatedEventArgs

public ref class ProtocolActivatedEventArgs sealed : IApplicationViewActivatedEventArgs, IProtocolActivatedEventArgs, IProtocolActivatedEventArgsWithCallerPackageFamilyNameAndData, IViewSwitcherProvider
public ref class ProtocolActivatedEventArgs sealed : IActivatedEventArgsWithUser, IApplicationViewActivatedEventArgs, IProtocolActivatedEventArgs, IProtocolActivatedEventArgsWithCallerPackageFamilyNameAndData, IViewSwitcherProvider
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class ProtocolActivatedEventArgs final : IApplicationViewActivatedEventArgs, IProtocolActivatedEventArgs, IProtocolActivatedEventArgsWithCallerPackageFamilyNameAndData, IViewSwitcherProvider
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class ProtocolActivatedEventArgs final : IActivatedEventArgsWithUser, IApplicationViewActivatedEventArgs, IProtocolActivatedEventArgs, IProtocolActivatedEventArgsWithCallerPackageFamilyNameAndData, IViewSwitcherProvider
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class ProtocolActivatedEventArgs : IApplicationViewActivatedEventArgs, IProtocolActivatedEventArgs, IProtocolActivatedEventArgsWithCallerPackageFamilyNameAndData, IViewSwitcherProvider
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class ProtocolActivatedEventArgs : IActivatedEventArgsWithUser, IApplicationViewActivatedEventArgs, IProtocolActivatedEventArgs, IProtocolActivatedEventArgsWithCallerPackageFamilyNameAndData, IViewSwitcherProvider
Public NotInheritable Class ProtocolActivatedEventArgs
Implements IApplicationViewActivatedEventArgs, IProtocolActivatedEventArgs, IProtocolActivatedEventArgsWithCallerPackageFamilyNameAndData, IViewSwitcherProvider
Public NotInheritable Class ProtocolActivatedEventArgs
Implements IActivatedEventArgsWithUser, IApplicationViewActivatedEventArgs, IProtocolActivatedEventArgs, IProtocolActivatedEventArgsWithCallerPackageFamilyNameAndData, IViewSwitcherProvider
繼承
Object Platform::Object IInspectable ProtocolActivatedEventArgs
屬性
實作

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

範例

OnActivated 事件處理常式會收到所有啟用事件。 屬性會指出啟用事件的類型。 此範例設定為處理 URI 啟用事件。

public partial class App
{
   protected override void OnActivated(IActivatedEventArgs args)
   {
      if (args.Kind == ActivationKind.Protocol)
      {
         ProtocolActivatedEventArgs eventArgs = args as ProtocolActivatedEventArgs;

         // TODO: Handle URI activation
         // The received URI is eventArgs.Uri.AbsoluteUri
      }
   }
}
Private Sub OnFileActivated(ByVal args As Windows.ApplicationModel.Activation.IActivatedEventArgs)
   If args.Kind = ActivationKind.Protocol Then
      ProtocolActivatedEventArgs eventArgs = args As ProtocolActivatedEventArgs

      ' TODO: Handle URI activation
      ' The received URI is eventArgs.Uri.AbsoluteUri
   End If
End Sub
void App::OnActivated(Windows::ApplicationModel::Activation::IActivatedEventArgs const& args)
{
    if (args.Kind() == Windows::ApplicationModel::Activation::ActivationKind::Protocol)
    {
        auto eventArgs{ args.as<Windows::ApplicationModel::Activation::ProtocolActivatedEventArgs>() };

        // TODO: Handle URI activation.
        // The received URI is eventArgs.Uri().RawUri().
    }
}
void App::OnActivated(Windows::ApplicationModel::Activation::IActivatedEventArgs^ args)
{
   if (args->Kind == Windows::ApplicationModel::Activation::ActivationKind::Protocol)
   {
      Windows::ApplicationModel::Activation::ProtocolActivatedEventArgs^ eventArgs = 
          dynamic_cast<Windows::ApplicationModel::Activation::ProtocolActivatedEventArgs^>(args);

      // TODO: Handle URI activation  
      // The received URI is eventArgs->Uri->RawUri
   } 
}

備註

當您實作事件處理常式以在ActivationKindProtocol時回應Activated事件時,就會存取此物件。

使用 C++、C# 或 Visual Basic 的 UWP 應用程式通常會藉由覆寫 Application 物件的方法來實作啟用點。 預設範本 app.xaml 程式碼後置檔案一律包含 OnLaunched的覆寫,但定義 OnActivated 等其他啟用點的覆寫,取決於您的應用程式程式碼。 如果ActivationKindProtocol,則來自OnActivated的介面類別型IActivatedEventArgs可以轉換成 ProtocolActivatedEventArgs。

啟用案例所涉及的所有 應用程式 覆寫都應該在其實作中呼叫 Window.Activate

版本歷程記錄

Windows 版本 SDK 版本 新增值
1607 14393 User

屬性

CallerPackageFamilyName

取得啟動目前應用程式之應用程式的封裝系列名稱。

CurrentlyShownApplicationViewId

取得目前顯示之應用程式檢視的識別碼。

Data

從啟動目前應用程式的應用程式接收的資料。

Kind

取得啟用類型。

PreviousExecutionState

取得應用程式啟動前的執行狀態。

SplashScreen

取得啟動顯示畫面物件,該物件提供從啟動顯示畫面轉換到啟動之應用程式的相關資訊。

Uri

取得啟動應用程式的統一資源識別項 (URI) 。

User

取得應用程式已啟用的使用者。

ViewSwitcher

取得檢視切換器物件,可讓您設定應用程式的檢視。

適用於

另請參閱