在已注册的 uap:protocol 可执行文件中获取 URI 参数
Obtaining the URI argument within a registered uap:protocol executable
我有一个 C# WPF 应用程序,我在 MSIX 包中引用了它。
我还通过以下方式在我的 MSIX 包的 Package.appxmanifest 中注册了一个 URI 协议:
<uap:Extension Category="windows.protocol" EntryPoint="AppLauncher"
Executable="AppLauncher\AppLauncher.exe">
<uap:Protocol Name="app-drive" >
</uap:Protocol>
</uap:Extension>
目标是当我在文件资源管理器或浏览器中键入 app-drive:\C:\test.txt
以启动我的可执行文件时,我希望在其中可以访问以下字符串 C:\test.txt
.
在我安装 MSIX 程序包并在任意位置输入该字符串后,我的程序可以正确启动,但找不到该参数。
到目前为止我尝试过的获取方式:
1.
[STAThread]
static void Main(string[] args)
{
// args[0] contains "-ServerName:App.AppXd****.mca" string
}
Environment.GetCommandLineArgs()
protected override void OnStartup(StartupEventArgs e)
所有这些仅包含字符串“-ServerName:App.AppXd****.mca”作为第一个参数。
请注意,我无法使用 Windows.ApplicationModel.AppInstance.GetActivatedEventArgs()
,因为我的应用程序不是 UWP。
有什么建议吗?
编辑:
找到了解决方案。事实证明,为了将参数传递给可执行文件,EntryPoint 必须是 EntryPoint="Windows.FullTrustApplication"
找到解决方案。事实证明,为了将参数传递给可执行文件,EntryPoint 必须是 EntryPoint="Windows.FullTrustApplication".
我有一个 C# WPF 应用程序,我在 MSIX 包中引用了它。 我还通过以下方式在我的 MSIX 包的 Package.appxmanifest 中注册了一个 URI 协议:
<uap:Extension Category="windows.protocol" EntryPoint="AppLauncher"
Executable="AppLauncher\AppLauncher.exe">
<uap:Protocol Name="app-drive" >
</uap:Protocol>
</uap:Extension>
目标是当我在文件资源管理器或浏览器中键入 app-drive:\C:\test.txt
以启动我的可执行文件时,我希望在其中可以访问以下字符串 C:\test.txt
.
在我安装 MSIX 程序包并在任意位置输入该字符串后,我的程序可以正确启动,但找不到该参数。
到目前为止我尝试过的获取方式:
1.
[STAThread]
static void Main(string[] args)
{
// args[0] contains "-ServerName:App.AppXd****.mca" string
}
Environment.GetCommandLineArgs()
protected override void OnStartup(StartupEventArgs e)
所有这些仅包含字符串“-ServerName:App.AppXd****.mca”作为第一个参数。
请注意,我无法使用 Windows.ApplicationModel.AppInstance.GetActivatedEventArgs()
,因为我的应用程序不是 UWP。
有什么建议吗?
编辑:
找到了解决方案。事实证明,为了将参数传递给可执行文件,EntryPoint 必须是 EntryPoint="Windows.FullTrustApplication"
找到解决方案。事实证明,为了将参数传递给可执行文件,EntryPoint 必须是 EntryPoint="Windows.FullTrustApplication".