C # take computer hardware information

zhaozj2021-02-16  96

C # take computer hardware information

// Take the CPU number

Private string getcpuid () {

ManagementClass MC = New ManagementClass ("Win32_Processor");

ManagementObjectCollection moc = mc.getinstances ();

String strcpuid = NULL;

Foreach (ManagementObject Mo in MoC) {

STRCPUID = mo.properties ["processorid"]. value.toString ();

Break;

}

Return STRCPUID;

} // End Method

// Take the first hard disk number

Private string getharddiskid () {

ManagementObjectSearcher Searcher = New ManagementObjectSearcher ("Select * from win32_physicalmedia);

String strharddiskid = null;

ManagementObject Mo in search.get ()) {

StrhardDiskid = Mo ["serialnumber"]. TOSTRING (). TRIM ();

Break;

}

Return Strharddiskid;

} // End Method

转载请注明原文地址:https://www.9cbs.com/read-11631.html

New Post(0)