|
Hey, I hadn't even though of supporting it this far...
No, seriously, I just wanted to put it out there for people to enjoy and then not have to think about it anymore. If you want to do it, be my guest...
Anything that is unrelated to elephants is irrelephant Anonymous
- The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944
- I'd just like a chance to prove that money can't make me happy. Me, all the time
|
|
|
|
|
Hey guys - great work
I have a question about extending this in the light of c++ VersionHelpers Version Helper functions (Windows)[^]
To get additional functionality I required, I started with
#region c++ VersionHelper Equivalents
public static bool IsWindowsVistaOrGreater()
return Version.CompareTo(new Version(6,0)) >= 0;
}
public static bool IsWindows7OrGreater()
return Version.CompareTo(new Version(6,1)) >= 0;
}
<h1>endregion c++ VersionHelper Equivalents
While these and similar functions would have the functionality I require, Im worried that we now have two different levels of mappings - the Major & Minor Id's -> OS Name and now my magic numbers as in Quote: new Version(6,0)
So, what are your thoughts on
- should I bother extending your work or start afresh (kinda grates on me to have 2 products doing almost the same thing)
- If I extend your work would not having a centralised 'table' holding all the 'magic' version numbers make sense ? (not sure what I'd use yet, just toying with the idea) .. It looks like I'd need to map
Name (string) -> PlatformID, majorVersion, minorVersion, csdVersion, productType
[edit] subject to some tweaks, this Version Helper API for .NET[^] covers the guts of the functionality in the c++ version - I think it just needs updating to use RtlGetVersion - I'll play with both, Im still not happy about having both methods, but I need to get cracking anyway, so it will do for now [/edit]
modified 23-Aug-16 22:06pm.
|
|
|
|
|
Windows 10 Anniversary Update returns a version number of 6.3 (instead of 6.2), thus meaning the current Windows 10 check is completely bypassed. I have modified the existing code to take this into account...
<br />
if (majorVersion == 6 && (minorVersion == 2 || minorVersion == 3))<br />
...though I am yet to test this properly.
|
|
|
|
|
Actually, that isn't going to be the full story.
Instead of that, this may be better...
if (majorVersion == 6)
{
string exactVersion = RegistryRead(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CurrentVersion", "");
if (!string.IsNullOrEmpty(exactVersion))
{
string[] splitResult = exactVersion.Split('.');
majorVersion = Convert.ToInt32(splitResult[0]);
minorVersion = Convert.ToInt32(splitResult[1]);
}
if (IsWindows10())
{
majorVersion = 10;
string Build = RegistryRead(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ReleaseId", "");
minorVersion = Convert.ToInt32(Build);
}
}
And...
case 10:
switch (minorVersion)
{
case 0:
switch (productType)
{
case 1:
name = "Windows 10";
break;
case 3:
name = "Windows Server 2016";
break;
}
break;
case 1507:
name = "Windows 10 (Version 1507)";
break;
case 1511:
name = "Windows 10 November Update (Version 1511)";
break;
case 1607:
name = "Windows 10 Anniversary Update (Version 1607)";
break;
}
break;
modified 9-Aug-16 22:17pm.
|
|
|
|
|
Thanks a lot for your findings! I really appreciate that!
/Johnny J.
Anything that is unrelated to elephants is irrelephant Anonymous
- The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944
- I'd just like a chance to prove that money can't make me happy. Me, all the time
|
|
|
|
|
How do you get this part to work?
Vader_Oz wrote: <pre lang="C#">case 10:
switch (minorVersion)
{
case 0:
switch (productType)
{
case 1:
name = "Windows 10";
break;
case 3:
name = "Windows Server 2016";
break;
}
break;
case 1507:
name = "Windows 10 (Version 1507)";
break;
case 1511:
name = "Windows 10 November Update (Version 1511)";
break;
case 1607:
name = "Windows 10 Anniversary Update (Version 1607)";
break;
}
break;</pre>
i have pastet the lines in to my class but when i start op the program it just say Windows 10.
I have made the manifest standard file in my project
|
|
|
|
|
I looked into this further as I needed it to work.
static public string Name
{
get
{
string name = "unknown";
<pre>
OperatingSystem osVersion = Environment.OSVersion;
OSVERSIONINFOEX osVersionInfo = new OSVERSIONINFOEX();
osVersionInfo.dwOSVersionInfoSize = Marshal.SizeOf(typeof(OSVERSIONINFOEX));
if (GetVersionEx(ref osVersionInfo))
{
int majorVersion = osVersion.Version.Major;
int minorVersion = osVersion.Version.Minor;
switch (majorVersion)
{
case 6:
string exactVersion = RegistryRead(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "CurrentVersion", "");
if (!string.IsNullOrEmpty(exactVersion))
{
string[] splitResult = exactVersion.Split('.');
majorVersion = Convert.ToInt32(splitResult[0]);
minorVersion = Convert.ToInt32(splitResult[1]);
}
break;
case 10:
majorVersion = 10;
string Build = RegistryRead(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ReleaseId", "");
minorVersion = Convert.ToInt32(Build);
break;
}
switch (osVersion.Platform)
{
case PlatformID.Win32S:
name = "Windows 3.1";
break;
case PlatformID.WinCE:
name = "Windows CE";
break;
case PlatformID.Win32Windows:
{
if (majorVersion == 4)
{
string csdVersion = osVersionInfo.szCSDVersion;
switch (minorVersion)
{
case 0:
if (csdVersion == "B" || csdVersion == "C")
name = "Windows 95 OSR2";
else
name = "Windows 95";
break;
case 10:
if (csdVersion == "A")
name = "Windows 98 Second Edition";
else
name = "Windows 98";
break;
case 90:
name = "Windows Me";
break;
}
}
break;
}
case PlatformID.Win32NT:
{
byte productType = osVersionInfo.wProductType;
switch (majorVersion)
{
case 3:
name = "Windows NT 3.51";
break;
case 4:
switch (productType)
{
case 1:
name = "Windows NT 4.0";
break;
case 3:
name = "Windows NT 4.0 Server";
break;
}
break;
case 5:
switch (minorVersion)
{
case 0:
name = "Windows 2000";
break;
case 1:
name = "Windows XP";
break;
case 2:
name = "Windows Server 2003";
break;
}
break;
case 6:
switch (minorVersion)
{
case 0:
switch (productType)
{
case 1:
name = "Windows Vista";
break;
case 3:
name = "Windows Server 2008";
break;
}
break;
case 1:
switch (productType)
{
case 1:
name = "Windows 7";
break;
case 3:
name = "Windows Server 2008 R2";
break;
}
break;
case 2:
switch (productType)
{
case 1:
name = "Windows 8";
break;
case 3:
name = "Windows Server 2012";
break;
}
break;
case 3:
switch (productType)
{
case 1:
name = "Windows 8.1";
break;
case 3:
name = "Windows Server 2012 R2";
break;
}
break;
}
break;
case 10:
switch (minorVersion)
{
case 0:
switch (productType)
{
case 1:
name = "Windows 10";
break;
case 3:
name = "Windows Server 2016";
break;
}
break;
case 1507:
case 10240:
name = "Windows 10 (Version 1507)";
break;
case 1511:
case 10586:
name = "Windows 10 November Update (Version 1511)";
break;
case 1607:
case 14393:
name = "Windows 10 Anniversary Update (Version 1607)";
break;
case 1703:
case 15063:
name = "Windows 10 Creators Update (Version 1703)";
break;
case var Env when (minorVersion > 15063):
name = "Windows 10 Fall Creators Update (Version " + minorVersion.ToString() + ")";
break;
default:
name = "Windows 10 (Version " + minorVersion.ToString() + ")";
break;
}
break;
}
break;
}
}
}
_Name = name;
return name;
}
}</pre>
|
|
|
|
|
Hi,
first of all, thank you guys for this great solution.
I made some changes which I want to share:
Windows 10 uses a revision version stored in the registry
static public int RevisionVersion
{
get
{
if(IsWindows10())
{
string revisionString = RegistryRead(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "UBR", "");
int revision = 0;
int.TryParse(revisionString, out revision);
return revision;
}
return Environment.OSVersion.Version.Revision;
}
}
For reading a non string value I needed to change a part of the RegistryRead() method:
...
if (newRegistryPath != "")
{
OurKey = OurKey.OpenSubKey(newRegistryPath);
object value = OurKey.GetValue(Field, DefaultValue);
rtn = value.ToString();
OurKey.Close();
}
...
At last I changed VersionString for my personal request:
static public string VersionString
{
get
{
if (IsWindows10())
{
string releaseId = RegistryRead(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion", "ReleaseId", "");
return string.Format("{0} (Build: {1}.{2})", new object[] { releaseId, BuildVersion, RevisionVersion });
}
return string.Format("{0}.{1} (Build: {2})", new object[] { MajorVersion, MinorVersion, BuildVersion});
}
}
Examples for VersionString results:
Windows 7: 6.1 (Build: 7601) (Revision is always 0 or 65535 on Win7/Server2012)
Windows 10: 1511 (Build: 10586.494)
Hope it helps somebody.
Freddy
|
|
|
|
|
Hi Freddy
Thanks a lot for sharing your information, I'm sure that that will come in handy to a lot of people!
Best regards,
Johnny J.
Anything that is unrelated to elephants is irrelephant Anonymous
- The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944
- I'd just like a chance to prove that money can't make me happy. Me, all the time
|
|
|
|
|
When i run this application to find OS name on Windows 10.
It returns Windows 8
Is there new lib to get right Windows information.
Thanks
Manuraj
|
|
|
|
|
No, it's not that simple. For Windows 10 there are several new issues that weren't there before, and I simply haven't got time to straighten it out. Sorry.
I haven't heard of any newer libraries either
Anything that is unrelated to elephants is irrelephant Anonymous
- The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944
- I'd just like a chance to prove that money can't make me happy. Me, all the time
|
|
|
|
|
I'm going to take a look at this and try and get it working. Another article here on CP covers the Version Helper methods and a port of them to C#, and I am going to use those in my attempt.
I'm not sure if it will work (I updated the other lib to allow for WinX, and it works) but I hope to get something working.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
It would be so great if you could do this. Thanks a million! This article really gives me a bad conscience. I started it, and then I can't find the time to keep it updated. I've got so much right now, changing jobs in the end of January, and I've got to finish off everything at the old job first.
If you want, I'll add you as a co-author so that you can update the article when (and if) you get it sorted???
Anything that is unrelated to elephants is irrelephant Anonymous
- The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944
- I'd just like a chance to prove that money can't make me happy. Me, all the time
|
|
|
|
|
By the way: I've got a version I've been working on that implements 8.1 and an attempt at 10. I didn't get the latter to work, though, hence no publication.
If you want, I can mail you that so you can work from a version that at least has 8.1 implemented... (I think it works at least, but it's only tested on a few machines)???
There is a lot of issues with Win 10, you should know. Some things only work if the application is properly manifested. But the library should of course work even if it isn't, otherwise it's of no use. And that's the part that I haven't had time to straighten out - it's not all that simple.
Anything that is unrelated to elephants is irrelephant Anonymous
- The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944
- I'd just like a chance to prove that money can't make me happy. Me, all the time
modified 28-Dec-15 4:01am.
|
|
|
|
|
That would be great.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
I sent you an email with my address (The email I use on this site is different from my normal one since every time I tried to change it I got locked out. I am afraid to try again.)
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
Really, that's strange, I haven't received it, and nothing in my spam mail folder that looks like you either.
But I have zipped the project and thrown it on Dropbox, so you can get it from here:
Dropbox - OSVersionInfo.zip[^]
Good luck! I'm looking forward to hearing what you find out!
Anything that is unrelated to elephants is irrelephant Anonymous
- The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944
- I'd just like a chance to prove that money can't make me happy. Me, all the time
|
|
|
|
|
I did a bit of work and found that the only way to find if the OS is WinX is to use the registry. I will work some more on it tomorrow.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
I GOT IT WORKING![^]
IT WORKS!
EDIT: *$&&#^@@&$*! OneDrive! Keeps giving me links to random files!
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
modified 9-Jan-16 14:41pm.
|
|
|
|
|
I cannot see the link, unfortunately, but that's really cool! Does it even work for non-manifested applications?
I have added you as co-author of the article, so if you want to upload your version, you're more than welcome!
Anything that is unrelated to elephants is irrelephant Anonymous
- The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944
- I'd just like a chance to prove that money can't make me happy. Me, all the time
|
|
|
|
|
Try it now. OneDrive keeps giving me links to random files.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
I got it. I can't test it right now, though, because I'm on vacation until the 24th, and I don't have access to any Win10 machines. But I'll try it out as soon as I can!
Anything that is unrelated to elephants is irrelephant Anonymous
- The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944
- I'd just like a chance to prove that money can't make me happy. Me, all the time
|
|
|
|
|
I tried editing the article, but every time I do Firefox glitches and jumbles the page. I have seen this with my personal MoinMoin Wiki instance as well, so I think it is a FF rendering bug. Either that, or one of my (very few) extensions is borked.
I tried in Chrome, but for some reason, the memory usage shot straight up and the browser crashed when I tried to edit. (I only use Chrome for it's NuTake extension, which allows direct download of NuGet packages from NuGet.org, a very handy feature.)
I HATE Internet Exploder and Edge, so I won't even try them.
What do you get when you cross a joke with a rhetorical question?
The metaphorical solid rear-end expulsions have impacted the metaphorical motorized bladed rotating air movement mechanism.
Do questions with multiple question marks annoy you???
|
|
|
|
|
Hi Brisingr
I've FINALLY had time to test your updated version. Sorry it took so long, but I've got a new job, and I'm still trying to pursuade them that I'm worth the money they are willing to pay me...
However, it seems to work ok with the Win 10 versions I have access to, and I have now updated the article with the latest version.
Thanks a lot for taking the time to look at the problem when I didn't have. I really appreciate it! Good work!
Cheers,
Johnny
Anything that is unrelated to elephants is irrelephant Anonymous
- The problem with quotes on the internet is that you can never tell if they're genuine Winston Churchill, 1944
- I'd just like a chance to prove that money can't make me happy. Me, all the time
|
|
|
|
|
thank you
|
|
|
|