Custom URI Scheme

Custom URI Scheme (sometimes called a Pluggable Protocol Handler).

It allows a web browser to communicate with a locally installed desktop application. Instead of the browser trying to handle the link itself (like it does for http:// or https://), it hands the entire URL over to the Windows operating system, which then looks up which application is registered to handle that specific "protocol" (in your case, bimcloudqs).


How it Works

When you click a link like bimcloudqs://projectConstruction/..., the process follows these steps:

  1. The Browser: Recognizes that the prefix isn't a standard web protocol.
  2. The OS (Windows): Checks the Windows Registry to see if any application has claimed the bimcloudqs name.
  3. The Application: Windows launches the registered .exe, passing the entire URI string as a command-line argument.

Technical Reference

The authoritative documentation for this on Windows is provided by Microsoft under the title "Registering an Application to a URI Scheme."


How to Develop Your Own Solution

To create your own, you need two things: an executable program and a specific entry in the Windows Registry.

1. The Registry Entry

To register a scheme (let's call it mycustomapp), you need to create a hierarchy in the Registry under HKEY_CLASSES_ROOT. You can do this by creating a .reg file with the following content:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\mycustomapp]
"URL Protocol"=""
@="URL:My Custom Protocol"

[HKEY_CLASSES_ROOT\mycustomapp\shell]

[HKEY_CLASSES_ROOT\mycustomapp\shell\open]

[HKEY_CLASSES_ROOT\mycustomapp\shell\open\command]
@="\"C:\\Path\\To\\YourApp.exe\" \"%1\""

2. The Application Logic

Your application needs to be programmed to handle command-line arguments. When launched via the URI, the first argument passed to your program will be the full string.

Example (C# / .NET):

static void Main(string[] args)
{
    if (args.Length > 0)
    {
        string fullUri = args[0]; 
        // Logic to parse "mycustomapp://action?params..."
        Console.WriteLine("Received command: " + fullUri);
    }
}

3. The Web Trigger

Once the registry is set, you trigger it via a standard HTML link:

<a href="mycustomapp://doSomething?id=123">Launch Local App</a>

Crucial Security Warning

Since you are essentially allowing a website to run code on a user's machine, you must sanitize the input.

发表于 2026 年 3 月 7 日,星期六
更新于 2026 年 5 月 4 日,星期一