• IE调用客户端程序实例


    参考MSDN http://msdn.microsoft.com/en-us/library/aa767914.aspx 怎样为一个程序注册一个 URL 协议
    核心代码为注册表

    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\Alert]
    @="AlterProtocol"
    "URL Protocol"="C:\\Alert.exe"

    [HKEY_CLASSES_ROOT\Alert\DefaultIcon]
    @="C:\\Alert.exe,1"

    [HKEY_CLASSES_ROOT\Alert\shell]

    [HKEY_CLASSES_ROOT\Alert\shell\open]

    [HKEY_CLASSES_ROOT\Alert\shell\open\command]
    @="\"C:\\Alert.exe\" \"%1\""

    到这里已经为 Alert.exe 注册了一个叫  Alert 的协议。在IE地址栏输入 alert://Hello 便可启动客户端的Alert.exe 程序

    看Alert.exe的代码先:

    namespace Alert
    {
        class Program
        {
            static string ProcessInput(string s)
            {
                // TODO Verify and validate the input 
                // string as appropriate for your application.
                return s;
            }
    
            static void Main(string[] args)
            {
                Console.WriteLine("客户端程序调用");
                Console.WriteLine("Alert.exe 参数如下:\r\n");
                Console.WriteLine("Raw command-line: \n\t" + Environment.CommandLine);
    
                Console.WriteLine("\n\n参数:\n");
                foreach (string s in args)
                {
                    Console.WriteLine("\t" + ProcessInput(s));
                }
                Console.ReadKey();
    
            }
        }
    }

    如果您开启了360网页防火墙:首次运行 会出现这样的提示:
    360 
    放行即可。
    如果您的C盘没有Alert.exe:
    3601    3602
    运行的效果:
    3604

    附件下载: Alert.rar

  • 相关阅读:
    用python爬虫抓站的一些技巧总结
    使用python爬虫抓站的一些技巧总结:进阶篇
    Python模块学习:threading 多线程控制和处理
    Redis操作命令总结
    Redis介绍
    linux内核设计与实现笔记 进程调度
    Python常见数据结构整理
    Linux进程调度原理
    Python yield
    Qt之布局管理器
  • 原文地址:https://www.cnblogs.com/iImax/p/1732633.html
Copyright © 2020-2023  润新知