使用自定义的协议打开应用程序

编写程序

将 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;
}

注册表里添加协议

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

浏览器中测试

浏览器地址栏输入test-url-protocol://xxx(xxx 是参数)

相关文章:

  • 2022-03-04
  • 2022-01-03
  • 2021-07-14
  • 2021-12-05
  • 2021-04-17
  • 2021-12-19
猜你喜欢
  • 2021-11-30
  • 2021-09-01
  • 2021-09-12
  • 2022-12-23
  • 2021-09-01
相关资源
相似解决方案