Open Default Apps (or Any Other Settings) in Windows 10

Sometimes you need to open windows settings programmatically. In my case mostly due to security restrictions - you can’t just go around the OS and change the settings, you need to ask the user to do that.

Luckily Windows 10 makes it easy by supporting the ms-settings: URI scheme, and there are plethora of system dialogs you can open with it.

In my case, I needed to open “default apps” window (ms-settings:defaultapps) and this is how i did it:

Header:

void open_mssettings(const std::wstring name);

void open_default_apps();

Implementation:

void open_mssettings(const std::wstring name)
{
    wstring url(L"ms-settings:");
    url += name;

    HINSTANCE hi = ::ShellExecute(
        nullptr,
        L"open",
        url.c_str(),
        nullptr,
        nullptr,
        SW_SHOWDEFAULT);
}

void open_default_apps()
{
    open_mssettings(L"defaultapps");
}

Effect:

Have a question⁉ Contact me.