自訂URL Protocol

來源:互聯網
上載者:User
我很好奇PPStream等軟體,是怎麼樣做到點擊IE的超連結,就可以開啟本身的程式,上線找了一下發現原來簡單到暴。

用Regedit加上下列機碼就可以了。

  • HKEY_CLASSES_ROOT
    • URL Protocol Name
      (Default) = "URL Protocol Discription"
      URL Protocol = ""

      • DefaultIcon
        (Default) = "exe path"
      • shell

        • open

          • command
            (Default) = "exe path" "%1"

    這是我自己實作的範例
    機碼部份

  • HKEY_CLASSES_ROOT
    • UTP
    • (Default) = "URL Protocol Test"
      URL Protocol = ""

      • DefaultIcon
        (Default) = "C:\URLProtocolTest.exe"
      • shell

        • open

          • command
            (Default) = "C:\URLProtocolTest.exe" "%1"

    程式部份

    namespace UrlProtocolTest
    {
        class Program
        {
            static void Main(string[] args)
            {            
                if(args != null)
                {
                    Console.WriteLine(String.Join(",", args));                
                }
                Console.Read();
            }
        }
    }

        這樣在IE中點擊 UPT 開頭的就會執行我的Console程式了,如 UPT:hwade.cnblogs.com。

  •     自訂URL Protocol在IE實踐就如上例的簡單,但FireFox看檔案感覺很複雜,可能是我不熟FireFox編程吧,不過真的自訂了URL Protocol還要寫一支安裝檔,請他們(客戶)下載安裝,也挺累的。

    參考網站

    1. Registering an Application to a URL Protocol
    2. Register a Custom URL Protocol Handler
    3. Custom URL Protocol Handlers
    4. Creating a new protocol for Mozilla Firefox in C++

     

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.