Directly paste code:
Copy Code code as follows:
public class Osinfomation
{
public static string Osbit ()
{
Try
{
connectionoptions oconn = new ConnectionOptions ();
System.Management.ManagementScope managementscope = new System.Management.ManagementScope ("\\\\localhost", oconn);
System.Management.ObjectQuery ObjectQuery = new System.Management.ObjectQuery ("Select Addresswidth from Win32_ Processor ");
ManagementObjectSearcher mosearcher = new ManagementObjectSearcher (Managementscope, ObjectQuery);
Managementobjectcollection moreturncollection = null;
string addresswidth = null;
Moreturncollection = Mosearcher.get ();
foreach (ManagementObject oreturn in moreturncollection)
{
Addresswidth = oreturn["Addresswidth"]. ToString ();
}//www.heatpress123.net
return addresswidth;
}
Catch
{
Return "Get Error";
}
}
public static string Getosversion ()
{
String osbitstring = Osbit ();
String osversionstring = Environment.OSVersion.ToString ();
return string. Format (@ system: {0}. Bit: {1} ", osversionstring, osbitstring);
}
}
Call:
Copy Code code as follows:
static void Main (string[] args)
{
Console.WriteLine (Osinfomation.getosversion ());
Console.ReadLine ();
}