Upravit

Sdílet prostřednictvím


Launch the camera settings page

Windows defines a set of URIs that allow apps to launch the Windows Settings app and display a particular settings page. This article explains how to launch the Windows Settings app directly to the camera settings page and, optionally, navigate directly to the settings for a particular camera on the device. For more information, see Launch the Windows Settings app.

The camera settings URL

Starting with Windows 11, Build 22000, the URI ms-settings:camera launches the Windows Settings app and navigates to the camera settings page. Note that in previous versions of Windows, this same URI would launch the default camera application. In addition to the general camera settings page, you can append the query string parameter cameraId set to the symbolic link name, in escaped URI format, to launch directly to the settings page for the associated camera.

In the following example, the DeviceInformation class is used to retrieve the symbolic link name for the first video capture device on the current machine, if one exists. Next, LaunchUriAsync is called to launch the Windows Settings app. The ms-settings:camera Uri specifies that the camera settings page should be shown. The optional query string parameter cameraId is set to the symbolic link name for the camera, escaped with a call to Url.EscapeDataString, to specify that the settings for the associated camera should be shown.

private async void LaunchSettingsPage_Click(object sender, RoutedEventArgs e)
{
    var captureDevices = await DeviceInformation.FindAllAsync(DeviceClass.VideoCapture);
    if (captureDevices.Count() > 0)
    {
        var cameraSymbolicLink = captureDevices.First().Id;
        bool result = await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings:camera?cameraId=" + Uri.EscapeDataString(cameraSymbolicLink)));
    }

}