Created
April 9, 2016 03:45
-
-
Save mohemohe/44a09b9e9ce50afae9a7d2a9840cbc4f to your computer and use it in GitHub Desktop.
WMIを使用したOSバージョンチェック
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static void Main(string[] args) | |
| { | |
| var version = GetOsVersion(); | |
| if (version.Major < 10) | |
| { | |
| Console.WriteLine(@"死ね"); | |
| } | |
| else | |
| { | |
| Console.WriteLine(@"キミには人権がある"); | |
| } | |
| } | |
| static Version GetOsVersion() | |
| { | |
| var os = new ManagementObjectSearcher(@"SELECT * FROM Win32_OperatingSystem").Get().Cast<ManagementObject>().FirstOrDefault(); | |
| var version = os?[@"Version"]?.ToString(); | |
| return version != null ? new Version(version) : null; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment