我见过:

http://www..。 ftp://blah.blah..。 文件:/ / blah.blah…… 不真实:/ / blah.blah…… mailto: / / blah.blah……

你看到http和类似调用的第一部分是什么?

我可以自己登记吗?


当前回答

这对于每个浏览器都是不同的,在IE和windows中,你需要创建一个他们称之为可插入的协议处理程序。

基本步骤如下:

Implement the IInternetProtocol interface. Implement the IInternetProtocolRoot interface. Implement the IClassFactory interface. Optional. Implement the IInternetProtocolInfo interface. Support for the HTTP protocol is provided by the transaction handler. If IInternetProtocolInfo is implemented, provide support for PARSE_SECURITY_URL and PARSE_SECURITY_DOMAIN so the URL security zone manager can handle the security properly. Write the code for your protocol handler. Provide support for BINDF_NO_UI and BINDF_SILENTOPERATION. Add a subkey for your protocol handler in the registry under HKEY_CLASSES_ROOT\PROTOCOLS\Handler. Create a string value, CLSID, under the subkey and set the string to the CLSID of your protocol handler.

关于MSDN上的异步可插协议,请参阅windows方面的详细信息。windows SDK中也有一个示例。

快速谷歌还在codeproject上显示了本文:http://www.codeproject.com/KB/IP/DataProtocol.aspx。

Finally, as a security guy I have to point out that this code needs to be battle hardened. It's at a high risk because to do it reliably you can't do it in managed code and have to do it in C++ (I suppose you could use VB6). You should consider whether you really need to do this and if you do, design it carefully and code it securely. An attacker can easily control the content that gets passed to you by simply including a link on a page. For example if you have a simple buffer overflow then nobody better do this: <a href="custom:foooo{insert long string for buffer overflow here}"> Click me for free porn</a>

强烈考虑使用strsafe和VC8及以上编译器中包含的新的安全CRT方法。如果你不知道我在说什么,请访问http://blogs.msdn.com/michael_howard/archive/2006/02/27/540123.aspx。

其他回答

带有HTTP://,FTP://等的部分称为URI方案

您可以通过注册中心注册自己的网站。

HKEY_CLASSES_ROOT/
  your-protocol-name/
    (Default)    "URL:your-protocol-name Protocol"
    URL Protocol ""
    shell/
      open/
        command/
          (Default) PathToExecutable

来源:https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml http://msdn.microsoft.com/en-us/library/aa767914 (v = vs.85) . aspx

打开记事本,将下面的代码粘贴进去。将“YourApp”更改为应用程序的名称。

保存到YourApp。通过在资源管理器中单击它来注册并执行它。

就是这样!

REGEDIT4

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

[HKEY_CLASSES_ROOT\YourApp\DefaultIcon]
@="\"C:\\Program Files\\YourApp\\YourApp.exe\""

[HKEY_CLASSES_ROOT\YourApp\shell]

[HKEY_CLASSES_ROOT\YourApp\shell\open]

[HKEY_CLASSES_ROOT\YourApp\shell\open\command]
@="\"C:\\Program Files\\YourApp\\YourApp.exe\" \"%1\" \"%2\" \"%3\" \"%4\" \"%5\" \"%6\" \"%7\" \"%8\" \"%9\""

对于大多数微软产品(Internet Explorer, Office,“打开文件”对话框等),您可以注册一个应用程序,当带有适当前缀的URI被打开时运行。这是更常见的解释的一部分——如何实现您自己的协议。

Mozilla的解释在这里,Java -在这里。

这对于每个浏览器都是不同的,在IE和windows中,你需要创建一个他们称之为可插入的协议处理程序。

基本步骤如下:

Implement the IInternetProtocol interface. Implement the IInternetProtocolRoot interface. Implement the IClassFactory interface. Optional. Implement the IInternetProtocolInfo interface. Support for the HTTP protocol is provided by the transaction handler. If IInternetProtocolInfo is implemented, provide support for PARSE_SECURITY_URL and PARSE_SECURITY_DOMAIN so the URL security zone manager can handle the security properly. Write the code for your protocol handler. Provide support for BINDF_NO_UI and BINDF_SILENTOPERATION. Add a subkey for your protocol handler in the registry under HKEY_CLASSES_ROOT\PROTOCOLS\Handler. Create a string value, CLSID, under the subkey and set the string to the CLSID of your protocol handler.

关于MSDN上的异步可插协议,请参阅windows方面的详细信息。windows SDK中也有一个示例。

快速谷歌还在codeproject上显示了本文:http://www.codeproject.com/KB/IP/DataProtocol.aspx。

Finally, as a security guy I have to point out that this code needs to be battle hardened. It's at a high risk because to do it reliably you can't do it in managed code and have to do it in C++ (I suppose you could use VB6). You should consider whether you really need to do this and if you do, design it carefully and code it securely. An attacker can easily control the content that gets passed to you by simply including a link on a page. For example if you have a simple buffer overflow then nobody better do this: <a href="custom:foooo{insert long string for buffer overflow here}"> Click me for free porn</a>

强烈考虑使用strsafe和VC8及以上编译器中包含的新的安全CRT方法。如果你不知道我在说什么,请访问http://blogs.msdn.com/michael_howard/archive/2006/02/27/540123.aspx。

第一部分被称为协议,是的,你可以注册自己的协议。在Windows上(我假设你是在使用c#标签——抱歉Mono的粉丝们),它是通过注册表完成的。