Showing posts with label 【Visual Studio Visual Csharp】Is Laptop. Show all posts
Showing posts with label 【Visual Studio Visual Csharp】Is Laptop. Show all posts

Saturday, May 22, 2021

【Visual Studio Visual Csharp】Is Laptop, Desktop, Notebook, Portable, chassis type

using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; using System.Diagnostics; using System.Management; namespace isLaptopC { public partial class Form1 : Form { public Form1() { InitializeComponent(); } public enum ChassisTypes { Other = 1, Unknown, Desktop, LowProfileDesktop, PizzaBox, MiniTower, Tower, Portable, Laptop, Notebook, Handheld, DockingStation, AllInOne, SubNotebook, SpaceSaving, LunchBox, MainSystemChassis, ExpansionChassis, SubChassis, BusExpansionChassis, PeripheralChassis, StorageChassis, RackMountChassis, SealedCasePC } public static ChassisTypes GetCurrentChassisType() { ManagementClass systemEnclosures = new ManagementClass("Win32_SystemEnclosure"); foreach (ManagementObject obj in systemEnclosures.GetInstances()) { foreach (int i in (UInt16[])(obj["ChassisTypes"])) { if (i > 0 && i < 25) { return (ChassisTypes)i; } } } return ChassisTypes.Unknown; } private void button1_Click(object sender, EventArgs e) { MessageBox.Show(GetCurrentChassisType().ToString()); } } 

} 

Generate a catchy title for a collection of newfangled music by making it your own

Write a newfangled code fragment at an earlier stage to use it. Then call another method and make sure their input is the correct one. The s...