Registering a protocol handler in Windows 8

后端 未结 3 1921
无人及你
无人及你 2020-12-05 15:31

I\'m trying to register my application that will handle opening of links, e,g, http://stackoverflow.com. I need to do this explicitly for Windows 8, I have itworking in ear

3条回答
  •  独厮守ぢ
    2020-12-05 15:47

    LaunchUriAsync(Uri)

    Starts the default app associated with the URI scheme name for the specified URI. You can allow the user to specify, in this case.

    http://msdn.microsoft.com/library/windows/apps/Hh701476

        // Create the URI to launch from a string.
        var uri = new Uri(uriToLaunch);
    
        // Calulcate the position for the Open With dialog.
        // An alternative to using the point is to set the rect of the UI element that triggered the launch.
        Point openWithPosition = GetOpenWithPosition(LaunchUriOpenWithButton);
    
        // Next, configure the Open With dialog.
        // Here is where you choose the program.
        var options = new Windows.System.LauncherOptions();
        options.DisplayApplicationPicker = true;
        options.UI.InvocationPoint = openWithPosition;
        options.UI.PreferredPlacement = Windows.UI.Popups.Placement.Below;
    
        // Launch the URI.
        bool success = await Windows.System.Launcher.LaunchUriAsync(uri, options);
        if (success)
        {
           // URI launched: uri.AbsoluteUri
        }
        else
        {
            // URI launch failed.  uri.AbsoluteUri
    
        }
    

提交回复
热议问题