c# - How can I detect if my app is running on Windows 10 -


i'm looking means detect if c# app running on windows 10.

i had hoped environment.osversion trick, seems return version of 6.3.9600.0 on windows 8.1 , windows 10.

other solutions such this don't seem distinguish between windows 8 , windows 10 either.

any suggestions?


why need this?

because i'm using winforms webbrowser control host oauth page crashes , burns in older ie versions (my app connects user's nest account...).

by default, webbrowser control emulates ie7. using registry key, can tell emulate latest version of ie installed on host pc. however, value worked windows 8.1 (and pre-releases of windows 10) not work in final version of windows 10.

if @ registry found environment name:

hkey_local_machine\software\microsoft\windows nt\currentversion\productname 

for example product name windows 10 home:

registry

with code if windows 10:

 static bool iswindows10()  {      var reg = registry.localmachine.opensubkey(@"software\microsoft\windows nt\currentversion");       string productname = (string)reg.getvalue("productname");       return productname.startswith("windows 10");  } 

note: add using microsoft.win32; usings.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -