URI scheme launching

后端 未结 3 972
不知归路
不知归路 2021-01-30 15:06

I\'ve been given a task to create a protocol similar to callto:, that - upon clicking on a link with it - would automatically launch an installed aplication.

I followed

3条回答
  •  执笔经年
    2021-01-30 15:13

    The registration you show works perfectly fine for me when I try it on Windows 7. The local app I registered in place of SlicanP.exe ran fine when I invoked a slican: URL from the Start | Run menu, and from within the address bar of Windows Explorer. So the registration works.

    Do be aware that Internet Explorer runs in a lower integrity security context, so it may not have rights to run local programs. When I tried to click on an HTML link to a slican: URL, or type a slican: URL in the address bar, IE had trouble executing the local app (even after prompting for permission). I had to run IE as an administrator, then the local app ran just fine.

    Also, you really should not be creating a HKEY_CLASSES_ROOT\slican key directly. Create a HKEY_CURRENT_USER\Software\Classes\slican (current user only) or HKEY_LOCAL_MACHINE\Software\Classes\slican (all users) instead. Refer to MSDN for more details:

    HKEY_CLASSES_ROOT Key

    Merged View of HKEY_CLASSES_ROOT

    Update: Since it works in Windows 7, Microsoft probably changed how URL schemes are registered in Windows 8. For instance, phone/store apps use URI activation:

    URI activation (XAML).

    URI activation (HTML)

    The documentation says there are two ways to register a custom URI scheme:

    Internet Explorer uses two mechanisms for registering new pluggable protocol handlers. The first method is to register a URI scheme name and its associated application so that all attempts to navigate to a URI using that scheme launch the application (for example, registering applications to handle mailto: or news: URIs). The second method uses the Asynchronous Pluggable Protocols API, which allows you to define new protocols by mapping the URI scheme to a class.

    You are doing the first. Try using the second instead.

    However, I just noticed that "Asynchronous Pluggable Protocols" is listed on MSDN in the "Legacy APIs" section, and it has the following note:

    Third-party protocol implementations won't load in Windows Store apps using JavaScript, or in the Internet Explorer in the new Windows UI.

    So it may or may not work in Windows 8.

    Update: I just found this:

    Guidelines for file types and URIs

    In Windows 8, the relationship between apps and the file types they support differs from previous versions of Windows.

    Walkthrough: using Windows 8 Custom Protocol Activation

    The file type and protocol association model has changed in Windows 8. Apps are no longer able to programmatically set themselves as the default handler for a file type or protocol. Instead, now the user always controls what the default handler is for a file type or protocol.

    Your app can use existing protocols for communication, such as mailto, or create a custom protocol. The protocol activation extension enables you to define a custom protocol or register to handle an existing protocol.

    Also have a look at this:

    Setting mailto: protocol handler programmatically in Windows 8

    And this:

    Default Programs

提交回复
热议问题