Launch the Windows Settings app explains how to pull up the Windows Settings app using the ms-settings:
URI scheme. It also lists the supported URIs, including the ones this question is asking for (ms-settings:network-wifi
and ms-settings:display
).
While the documentation proposes using the Windows Runtime API Launcher.LaunchUriAsync
this is a fair bit complex with C (as opposed to C++). Since the URIs can be invoked from the command prompt using the start
command (e.g. start ms-settings:display
), it's reasonable to assume that ShellExecuteExW
can handle the ms-settings:
URI scheme as well.
And indeed, this does appear to work:
#include <Windows.h>
#include <stdio.h>
int main() {
SHELLEXECUTEINFOW sei = {
.cbSize = sizeof(sei),
.hwnd = NULL,
.lpVerb = L"open",
.lpFile = L"ms-settings:display",
//.lpFile = L"ms-settings:network-wifi",
.nShow = SW_SHOWNORMAL,
};
if (!ShellExecuteExW(&sei))
{
printf("Failed with error code %d", GetLastError());
}
}
I wasn't able to find any documentation that specifies this behavior, so this may well be an unsupported implementation detail. I will also mention that while SHELLEXECUTEINFOW
has an lpClass
field that can be used to specify a URI protocol scheme, none of my iterations to use it worked for the ms-settings:
URI scheme.