我只是在寻找一个示例项目来了解我应该如何实现我的应用程序。
就像在 torrent 文件中一样,我想通过网站链接在 WPF 应用程序中打开并触发一个事件。我该怎么做呢 ?
我只是在寻找一个示例项目来了解我应该如何实现我的应用程序。
就像在 torrent 文件中一样,我想通过网站链接在 WPF 应用程序中打开并触发一个事件。我该怎么做呢 ?
好的。这是我解决它的方法。
Windows 注册表编辑器版本 5.00
[HKEY_CLASSES_ROOT\KA] @="URL:KA 协议" "URL 协议"=""
[HKEY_CLASSES_ROOT\KA\shell]
[HKEY_CLASSES_ROOT\KA\shell\open]
[HKEY_CLASSES_ROOT\KA\shell\open\command]@="\"C:\Users\me\Desktop\myapp\myapp.exe\"\"%1\""
在 Internet Explorer 中键入 KA://myargument 以尝试处理 myapp.exe
在我的 WPF 应用程序中处理,就像在 App.cs 中一样
public partial class App : Application { void App_Startup(object sender, StartupEventArgs e) { for (int i = 0; i != e.Args.Length; ++i) { if (e.Args[i].StartsWith("ka:")) { int index = e.Args[i].IndexOf(':') +1; string argg= e.Args[i].Substring(index, e.Args[i].Length - index); // handling argument here } } Shell mainWindow = new Container(); mainWindow.Show(); } }
我会看看这个链接:
https://msdn.microsoft.com/en-us/library/aa767914%28v=vs.85%29.aspx
并创建 yourApp://WHatInfoYouNeed 的自定义 URL 方案