【问题标题】:How to pass args to a UWP Application with EntryPoint="Windows.FullTrustApplication" in AppxManifest.xml如何在 AppxManifest.xml 中使用 EntryPoint="Windows.FullTrustApplication" 将 args 传递给 UWP 应用程序
【发布时间】:2019-03-11 14:52:38
【问题描述】:

我正在尝试设置AppxManifest.xml 来启动 Win32 应用程序作为完全信任的应用程序。使用下面的 sn-p,我可以 Add-AppxPackage -Register AppxManifest.xml 然后使用 Debug > Other Debugging Tools > Debug Installed Application 在 Visual Studio 2017 中调试应用程序。

但是,我想在启动应用程序时将一些参数传递给应用程序。我怎样才能做到这一点?我不介意在AppxManifest.xml 中列出它们,如果这是最简单的,我只需要知道如何。

...
<Applications>
    <Application Id="App" Executable="SomeExecutable.exe" EntryPoint="Windows.FullTrustApplication">
      <uap:VisualElements DisplayName="Wrap" Description="Wrap" BackgroundColor="transparent" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png">
        <uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" />
      </uap:VisualElements>
    </Application>
  </Applications>
...

【问题讨论】:

标签: windows visual-studio uwp appxmanifest


【解决方案1】:

Protocol associations 就是你要找的东西:

协议关联可以启用其他程序和系统组件 与您的打包应用程序互操作。当您的打包应用程序 使用协议启动,可以指定具体参数 传递给它的激活事件参数,以便它可以做出相应的行为。 只有打包的、完全信任的应用支持参数

<Package
  xmlns:uap3="http://schemas.microsoft.com/appx/manifest/uap/windows10/3"
  xmlns:desktop="http://schemas.microsoft.com/appx/manifest/desktop/windows10"
  IgnorableNamespaces="uap3, desktop">
  <Applications>
    <Application>
      <Extensions>
        <uap3:Extension
          Category="windows.protocol">
          <uap3:Protocol
            Name="myapp-cmd"
            Parameters="/p " />
        </uap3:Extension>
      </Extensions>
    </Application>
  </Applications>
</Package>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-07-04
    • 1970-01-01
    • 2018-11-27
    • 2020-08-27
    • 2022-11-02
    • 2018-11-10
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多