UWP 协议启动
- 1.创建通过协议启动的项目 AppDemo
- 2.在项目的Package.appxmanifest 文件里 Extensions 目录下

<Extensions> <uap:Extension Category="windows.protocol"> <uap:Protocol Name="uridemo"> <uap:Logo>Assets\StoreLogo.png</uap:Logo> <uap:DisplayName>AppDemo</uap:DisplayName> </uap:Protocol> </uap:Extension> </Extensions>
- 3.在App.xaml.cs里

protected override void OnActivated(IActivatedEventArgs args) { base.OnActivated(args); // Window management Frame rootFrame = Window.Current.Content as Frame; if (rootFrame == null) { rootFrame = new Frame(); Window.Current.Content = rootFrame; } switch (args.Kind) { case ActivationKind.VoiceCommand: { break; } case ActivationKind.Protocol: { // Code specific to launch for results var command = args as ProtocolActivatedEventArgs; if (command.Uri.ToString().StartsWith("uridemo://")) { // Open the page that we created to handle activation for results. rootFrame.Navigate(typeof(MainPage), command); } else { //..... } break; } } // Ensure the current window is active. Window.Current.Activate(); }
- 4.在创建一个要启动的项目AppClient

private async void button_Click(object sender, RoutedEventArgs e) { await Windows.System.Launcher.LaunchUriAsync(new Uri("uridemo://appdata")); }
- 5.部署完成,启动AppClient
作者:androllen
出处:https://www.cnblogs.com/androllen/p/7722827.html
版权:本作品采用「署名-非商业性使用-相同方式共享 4.0 国际」许可协议进行许可。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】Flutter适配HarmonyOS 5知识地图,实战解析+高频避坑指南
【推荐】凌霞软件回馈社区,携手博客园推出1Panel与Halo联合会员
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 如何反向绘制出 .NET程序 异步方法调用栈
· 领域驱动设计实战:聚合根设计与领域模型实现
· 突破Excel百万数据导出瓶颈:全链路优化实战指南
· 如何把ASP.NET Core WebApi打造成Mcp Server
· Linux系列:如何用perf跟踪.NET程序的mmap泄露
· 聊聊 ruoyi-vue ,ruoyi-vue-plus ,ruoyi-vue-pro 谁才是真正的
· C#开发的Panel滚动分页控件 - 开源研究系列文章
· 如何反向绘制出 .NET程序 异步方法调用栈
· ShadowSql之开源不易
· Python 3.14 新特性盘点,更新了些什么?