Skip to content

Instantly share code, notes, and snippets.

@anaisbetts
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anaisbetts/9420720 to your computer and use it in GitHub Desktop.
Save anaisbetts/9420720 to your computer and use it in GitHub Desktop.
static bool IsWindows81OrHigher()
{
var notepad = Environment.ExpandEnvironmentVariables("%SystemRoot%\\Notepad.exe");
var realOsVersion = FileVersionInfo.GetVersionInfo(notepad);
return (new Version(realOsVersion.ProductVersion) >= new Version(6, 3, 0, 0));
}
@bennage
Copy link

bennage commented Mar 7, 2014

ha ha ha!

@bennage
Copy link

bennage commented Mar 7, 2014

I'm laughing with you, not at you.

@clairernovotny
Copy link

👍

@justinvp
Copy link

justinvp commented Mar 8, 2014

lolz. Very creative. And will work great until it is run on a machine where someone has swapped notepad.exe with a notepad replacement (despite the fact that there is a registry key that can be used to avoid replacing the actual binary).

Consider using "feature detection" instead of Windows version checks (e.g. use LoadLibrary and GetProcAddress to see if the library and function is available before using). See anaisbetts/PerMonitorDpi#1 for details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment