1

I'm just looking for a sample project to get an idea for how I should implement my application.

Just like in torrent files, I want to open and fire an event in a WPF application via a Website link. How do I do this ?

Kubi
  • 2,139
  • 6
  • 35
  • 62
  • Interesting question... I know there's MonoTorrent, but I don't know if it would give you the amount of freedom you're looking for. You could, of course, look at their source code and see how they did it: https://github.com/mono/monotorrent I should warn you, though... that the question is completely off-topic, due to how you're asking it (3rd party library). I would reword it before it gets closed down. – B.K. May 08 '15 at 22:16
  • I'm removing it and I could manage to solve my problem. I'll post the answer tomorrow in case others might need it – Kubi May 08 '15 at 22:31

2 Answers2

3

OK. Here is how I solved it.

  1. I'm adding the registry key to register custom URL Scheme first

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\KA] @="URL:KA Protocol" "URL Protocol"=""

[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\""

  1. Typing KA://myargument in Internet Explorer to try to process myapp.exe

  2. Handling in my WPF app as this in 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();
        }
    }
    
Kubi
  • 2,139
  • 6
  • 35
  • 62
1

I would check out this link:

https://msdn.microsoft.com/en-us/library/aa767914%28v=vs.85%29.aspx

and create a custom URL scheme of yourApp://WHatInfoYouNeed

mageos
  • 1,216
  • 7
  • 15