1. 程式人生 > >瀏覽器-啟動本地程式

瀏覽器-啟動本地程式

(未完成)

使用自定義的協議開啟應用程式

  1. 編寫程式
    將test.exe儲存到c盤根目錄
#include <stdio.h>
int main(int argc, char** argv)
{
    int i;
    printf("hello world!\n");
    for (i = 0; i < argc; ++i)
    {
        printf("argv[%d] = %s\n", i, argv[i]);
    }
    getchar();
    return 0;
}
  1. 登錄檔裡新增協議
    test.reg儲存到c盤根目錄,並雙擊執行
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\test-url-protocol]
"URL Protocol"="c:\\test.exe"
@="fooProtocol"
[HKEY_CLASSES_ROOT\test-url-protocol\shell]
[HKEY_CLASSES_ROOT\test-url-protocol\shell\open]
[HKEY_CLASSES_ROOT\test-url-protocol\shell\open\command]
@="\"c:\\test.exe\" \"%1\""
  1. 瀏覽器中測試
    瀏覽器位址列輸入test-url-protocol://xxx(xxx是引數)