Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[NET] Get Operating system product line

Featured Replies

So I'm writing this little app in .NET, but I'm having some troubles getting the Operating System type. I can already get the OS version (Windows 2000/XP, etc), but I need to get Home/Pro etc.


System.OperatingSystem osInfo = System.Environment.OSVersion;
string windowsVersion = "Windows Version: ";
int servicePack = 0;

// Determine the platform.
switch (osInfo.Platform)
{
case System.PlatformID.Win32Windows:
MessageBox.Show("This program is not supported on this version of Windows.");
System.Environment.Exit(0);
break;

case System.PlatformID.Win32NT:

switch (osInfo.Version.Major)
{
case 3:
case 4:
MessageBox.Show("This program is not supported on this version of Windows.");
System.Environment.Exit(0);
break;
case 5:
if (osInfo.Version.Minor == 0)
{
windowsVersion += "Windows 2000";
windowsVersion += osInfo.ServicePack.ToString();
MessageBox.Show("Windows 2000");
}
else
{
windowsVersion += "Windows XP ";
OSVERSIONINFOEX osVersion = new OSVERSIONINFOEX();
GlobalFunctions.GetVersionEx(osVersion);
switch(osVersion.SuiteMask)
{
case 0x00000200:
windowsVersion += "Home Edition ";
break;
default:
windowsVersion += "Professional ";
break;
}
switch (osInfo.ServicePack)
{
case "Service Pack 2":
windowsVersion += "Service Pack 2";
servicePack = 2;
break;
case "Service Pack 1":
windowsVersion += "Service Pack 1";
servicePack = 1;
break;
}
}
break;
} break;
}

I'm importing the GetVersionEx function from kernel32.dll. I'm guessing the problem comes from the enumerated data types that aren't properly passed over...

Any ideas?


Once you figure it out, I claim first dibs on beta testing! ;)

  • Author

Thanks GSM - that's pretty much exactly what I want. I just don't know how to turn that VB.NET code into C#.NET... :P

The My namespace doesn't exist in .NET, and I've yet to find an equivalent. That's why I moved towards importing the API import (as per jcarle's suggestion over MSN).

EDIT - I think I got it actually... I sent a spoof program that just spits out information to a friend of mine, and got him to send me back the info. :)

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.