How to create own URL Protocol In Windows

Creating your own URL protocol in Windows allows you to define custom behavior when a specific protocol is used in a URL. Here’s how to create one:

Steps to Create a Custom URL Protocol

1. Open the Windows Registry Editor:

* Pre…


This content originally appeared on DEV Community and was authored by Avinash Tare

Creating your own URL protocol in Windows allows you to define custom behavior when a specific protocol is used in a URL. Here's how to create one:

Steps to Create a Custom URL Protocol

1. Open the Windows Registry Editor:

* Press Win + R, type *regedit*, and hit Enter.

open windows registry

2. Navigate to the Protocols Section:

  • Go to HKEY_CLASSES_ROOT in the registry.
  • Right-click on HKEY_CLASSES_ROOT and select New > Key.

find folder

  • Name this key after your custom protocol (e.g., myapp).

create folder

3. Define the Default Value:

  • Double clickon (Defualt).
  • Write any thing about you protocol (e.g,. my app protocol)
  • press ok.

Image description

  • Create New string value.

Image description

  • add value URL Protocol it's required.

add new value

  • Now Your app is ready you can check on google chrome but we have add .exe file corresponding to our URL.

4. Create a Shell Subkey:

  • Inside your protocol key (e.g., myapp), right-click and create a new key named shell.

create new key

  • name of the key is shell:

shell key

5. Create an open Key Inside the shell Key:

  • Right-click the shell key, select New > Key, and name it open.

open key

6. Create a command Key Inside the open Key:

  • Right-click the open key, select New > Key, and name it command.

command key

7. Define the Command to Execute:

  • Click on the command key, and in the right-hand pane, double-click the (Default) entry. Set the value to the path of the executable you want to run, followed by "\"%1\"" (including the quotes). For example:

add exe file and args

  • press ok, you protocol created successfully.

8. Creating Test Program

  • Creating a program using c to get arguments. you can use any langualge.
#include <stdio.h>
#include <conio.h>

int main(int argc, char *argv[])
{
    printf("Argument: \n%s", argv[1]);

    getch();
    return 0;
}
  • Convert Into Exe using c++ myapp.c -o myapp.exe;
  • now you add this exe into command defualt value.

9: Test Your Protocol

  • goto chrome and write you myapp://hello

Chrome url

  • it's open a modal to open url.

Image description

  • OUTPUT:-

Image description

  • Now you can parse this url and do anyting what you want.

Follow Me on GitHub Avinash Tare


This content originally appeared on DEV Community and was authored by Avinash Tare


Print Share Comment Cite Upload Translate Updates
APA

Avinash Tare | Sciencx (2024-08-05T20:33:30+00:00) How to create own URL Protocol In Windows. Retrieved from https://www.scien.cx/2024/08/05/how-to-create-own-url-protocol-in-windows/

MLA
" » How to create own URL Protocol In Windows." Avinash Tare | Sciencx - Monday August 5, 2024, https://www.scien.cx/2024/08/05/how-to-create-own-url-protocol-in-windows/
HARVARD
Avinash Tare | Sciencx Monday August 5, 2024 » How to create own URL Protocol In Windows., viewed ,<https://www.scien.cx/2024/08/05/how-to-create-own-url-protocol-in-windows/>
VANCOUVER
Avinash Tare | Sciencx - » How to create own URL Protocol In Windows. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/08/05/how-to-create-own-url-protocol-in-windows/
CHICAGO
" » How to create own URL Protocol In Windows." Avinash Tare | Sciencx - Accessed . https://www.scien.cx/2024/08/05/how-to-create-own-url-protocol-in-windows/
IEEE
" » How to create own URL Protocol In Windows." Avinash Tare | Sciencx [Online]. Available: https://www.scien.cx/2024/08/05/how-to-create-own-url-protocol-in-windows/. [Accessed: ]
rf:citation
» How to create own URL Protocol In Windows | Avinash Tare | Sciencx | https://www.scien.cx/2024/08/05/how-to-create-own-url-protocol-in-windows/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.