How can I detect programmatically whether Windows is an N or KN version?

Raymond Chen

A customer was dealing with a problem that occurred only when running on an N or KN version of Windows. These versions of Windows are special versions that omit the multimedia features.¹ Microsoft is legally required to offer these versions of Windows in certain jurisdictions, although in practice, the number of people who buy them is vanishingly small. (It sometimes feels like the sole reason those customers exist is to file bugs that reproduce only on N and KN versions.)

The customer wanted to know how to detect that the user is running an N or KN version of Windows, so they could disable the features of the product that depend upon multimedia support.

The answer is that you don’t check whether you are on an N or KN version of Windows. Rather, you check whether multimedia support is present.

Because the user, after buying an N or KN version of Windows (perhaps inadvertently), can later download and install the Media Feature Pack and restore multimedia support. In that case, they expect your program to enable its multimedia features.

So really, what you want to do is detect whether multimedia support is present. One way to do that is to see if you can call the MFStartup function, and whether it succeeds. If not, then Media Foundation is not available, and multimedia features are not available.

This particular customer had a Web-based app, in which case they can use HTMLMediaElement.canPlayType to detect whether the system can play their media, and skip the video if so.

Bonus chatter: The bug was that if you asked to see the training video, the video didn’t play (expected), but the app also hung (not expected). The reason is that the app tried to play the video roughly like this:

var video = document.queryselector("#training-video");
video.src = "/videos/training.mp4";
video.addEventListener("error", onVideoFinished);
video.addEventListener("ended", onVideoFinished);

If multimedia support is not present, the error event is raised immediate upon setting the src property. But the code hasn’t registered a handler for that event, so the error event is raised, but nobody is there to handle it. The app later adds a handler, but it’s too late. That’s why the app appeared to hang.

To deal with errors that occur immediately, the app should register the event handlers before setting the source.

(Note that canPlayType is still useful, even after they fix this race condition. That lets them detect that the system cannot play the training video at all, and they can remove the “Play training video” option from their interface, or replace it with an explanation of why the training video is not available.)

¹ The KN version also omits Windows Messenger, but since Windows Messenger itself has been discontinued, the distinction is meaningless in practice.


Discussion is closed. Login to edit/delete existing comments.

  • skSdnW 0

    And if you wanted to display the full Windows edition name somewhere you would be facing GetProductInfo and the largest switch statement known to man, filled with undocumented values you find on random sites, so spare yourself the trouble and just don’t do it.

  • Joshua Hudson 0

    I was really annoyed to discover that in Windows 10, they take different activation keys. I wanted to use the US N version (yes it exists; check msdn) only to discover that a normal retail key won’t activate an N edition. It was being installed in a VM with no graphics acceleration and there was zero chance that media functions would work, so why waste disk space and attack surface.

Feedback usabilla icon