Hack Forums
[C#] Operating system (Help Please) - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [C#] Operating system (Help Please) (/showthread.php?tid=6032764)



Operating system (Help Please) - __Digital__ - Dec 14, 2019

Hello everyone i have not asked for help in while but when i am trying to pull the osversion fr windows 10 and it reads as windows 8.

My code is here:

Code
public static string OSName()
        {
            string osName = "";
            OperatingSystem oSVersion = Environment.OSVersion;
            if (oSVersion.Platform == PlatformID.Win32NT)
            {
                if (oSVersion.Version.Major == 5)
                {
                    switch (oSVersion.Version.Minor)
                    {
                        case 0:
                            osName = "2K";
                            break;

                        case 1:
                            osName = "XP";
                            break;

                        case 2:
                            osName = "2k3";
                            break;
                    }
                }
                if (oSVersion.Version.Major == 6)
                {
                    switch (oSVersion.Version.Minor)
                    {
                        case 0:
                            osName = "VI";
                            break;

                        case 1:
                            osName = "W7";
                            break;

                        case 2:
                            osName = "W8";
                            break;
                        

                    }
                }
               if(oSVersion.Version.Major == 10)
                  {
                     switch (oSVersion.Version.Minor)
                      {
                          case 0:
                             osName = "W10";
                              break;
            }
}
}

I am trying to get the correct major and minor numbers so it will read the correct operating system. I'm sure i am making a mistake somewhere but can't figure it out. It reads windows 10 as windows 8


RE: Operating system (Help Please) - HFDone - Dec 14, 2019

https://stackoverflow.com/questions/2819934/detect-windows-version-in-net


RE: Operating system (Help Please) - __Digital__ - Dec 14, 2019

(Dec 14, 2019 11:00 AM)HFDone Wrote:  https://stackoverflow.com/questions/2819934/detect-windows-version-in-net

Yes i have looked at all that and even with correct changes it still reads as windows 8 when its a windows 10 machine.


RE: Operating system (Help Please) - NYANxCAT - Dec 14, 2019

https://docs.microsoft.com/en-us/dotnet/api/microsoft.visualbasic.devices.computerinfo.osfullname?view=netframework-4.8


PHP Code

<?php 
new ComputerInfo().OSFullName.ToString() 



RE: Operating system (Help Please) - HFDone - Dec 14, 2019

https://www.prugg.at/2019/09/09/properly-detect-windows-version-in-c-net-even-windows-10


RE: Operating system (Help Please) - itcorp - Dec 14, 2019

(Dec 14, 2019 11:22 AM)__Digital__ Wrote:  Yes i have looked at all that and even with correct changes it still reads as windows 8 when its a windows 10 machine.

if you really want to use this helper class what prevents you to modify it ,because generally you have more or less everything there and changes thet you will make there is very easy following an already existing concept.


RE: Operating system (Help Please) - Bunnyslippers69 - Dec 14, 2019

You could try something similar to this. Returns the version number of the OS. Can be used to find the name of the OS using this page.



My bad if a better method exists. This is just what came to mind.