I have seen:
http://www...
ftp://blah.blah...
file://blah.blah...
unreal://blah.blah...
mailto://blah.blah...
What is that first section where you see http
and the like called?
Can I register my own?
I have seen:
http://www...
ftp://blah.blah...
file://blah.blah...
unreal://blah.blah...
mailto://blah.blah...
What is that first section where you see http
and the like called?
Can I register my own?
The portion with the HTTP://
,FTP://
, etc are called URI Schemes
You can register your own through the registry.
HKEY_CLASSES_ROOT/
your-protocol-name/
(Default) "URL:your-protocol-name Protocol"
URL Protocol ""
shell/
open/
command/
(Default) PathToExecutable
Sources: https://www.iana.org/assignments/uri-schemes/uri-schemes.xhtml, http://msdn.microsoft.com/en-us/library/aa767914(v=vs.85).aspx
(Default)
here means empty string. Don't take it literally. –
Luciferous http://
, mailto://
, tel://
, or, I dunno, fish://
. –
Duodiode mailto:
URI scheme, but that has nothing to do with the registration of a handler for URIs of the mailto:
scheme. The OS simply doesn't care, it's the program that handles the scheme that does all of that. Windows treats all URIs in exactly the same way, at least insofar as I know, it passes along the URI as an argument to the specified handler program. –
Duodiode [HKEY_CLASSES_ROOT\your-protocol-name\Application]
"ApplicationName"="Your Application Name"
–
Blayze [HKEY_CURRENT_USER\SOFTWARE\Classes\your-protocol-name]
instead of [HKEY_CLASSES_ROOT\your-protocol-name]
without admin priviledges. –
Blayze Open notepad and paste the code below into it. Change "YourApp" into your app's name.
Save it to YourApp.reg and execute it by clicking on it in explorer.
That's it!
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\""
@="URL:YourApp Protocol"
is an optional one? I have problem in IE 11 on Win 7 SP1, in which my custom URL protocol having problem, where it runs just fine in any other browser+windows version. –
Mayoralty .reg file
one time it will tell the system to use your app when you type in that protocol. Just to repeat, you only need to run this code once per system to register your app to the protocol. –
Sabella This is different for each browser, in IE and windows you need to create what they call a pluggable protocol handler.
The basic steps are as follows:
See About Asynchronous Pluggable Protocols on MSDN for more details on the windows side. There is also a sample in the windows SDK.
A quick google also showed this article on 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>
Strongly consider using strsafe and the new secure CRT methods included in the VC8 and above compilers. See http://blogs.msdn.com/michael_howard/archive/2006/02/27/540123.aspx if you have no idea what I'm talking about.
Here's a list of the registered URI schemes. Each one has an RFC - a document defining it, which is almost a standard. The RFC tells the developers of new applications (such as browsers, ftp clients, etc.) what they need to support. If you need a new base-level protocol, you can use an unregistered one. The other answers tell you how. Please keep in mind you can do lots of things with the existing protocols, thus gaining their existing implementations.
mqtt://
which isn't registered on the list. –
Kutaisi For most Microsoft products (Internet Explorer, Office, "open file" dialogs etc) you can register an application to be run when URI with appropriate prefix is opened. This is a part of more common explanation - how to implement your own protocol.
It's called the protocol. The only thing that prevents you from making your own protocol is you have to:
Windows makes #1 really easy, an in many cases this is all you actually need. Viz:
The first section is called a protocol and yes you can register your own. On Windows (where I'm assuming you're doing this given the C# tag - sorry Mono fans), it's done via the registry.
You don't really have to do any registering as such. I've seen many programs, like emule, create their own protocol specificier (that's what I think it's called). After that, you basically just have to set some values in the registry as to what program handles that protocol. I'm not sure if there's any official registry of protocol specifiers. There isn't really much to stop you from creating your own protocol specifier for your own application if you want people to open your app from their browser.
© 2022 - 2024 — McMap. All rights reserved.