c 獲取本機電腦相關資訊

2021-08-22 07:52:18 字數 1155 閱讀 2087

建立乙個類.然後讀取資訊.呼叫**如下.

hardinfoclass myclass=new hardinfoclass();

textbox1.text=myclass.getharddiskid();

textbox2.text=myclass.getcpuid();

textbox3.text=myclass.getnetcardmac();

textbox4.text=myclass.getnetcardip();

textbox5.text=myclass.gethostname();

textbox6.text=myclass.getvolof("d");//c盤58c6b679跟d盤6ed62864不一樣

類hardinfoclass**如下

using system;

using system.net;

using system.runtime.interopservices;

using system.management; //需要在解決方案中引用system.management.dll檔案

namespace filetranslate.pcstatus

//取機器名

public string gethostname()

//取cpu編號

public string getcpuid()

return strcpuid;

} catch

}//end method

//取第一塊硬碟編號

public string getharddiskid()

return strharddiskid ;

} catch }

//獲取網絡卡mac位址

public string getnetcardmac() }

return stringmac;

} catch

}//獲取硬碟資訊的**

public string getvolof(string drvid)

catch

} //獲取當前網絡卡ip位址

public string getnetcardip() }

return stringip;

} catch }}

}

C 獲取電腦的相關資訊

建立者 菜刀居士的部落格 建立日期 2014年08月31號 功能 獲取電腦的相關資訊 public class computerhelper return string.empty 獲取網絡卡mac位址 public static string getmacaddress return string...

如何獲取本機電腦的AD網域名稱稱

如何獲取本機電腦的ad網域名稱稱,該 參考了msdn幫助文件裡面所寫的內容 define win32 winnt 0x0500 include include include void tmain void int cnf 0 dword dwsize sizeof buffer for cnf 0...

C 獲取自己電腦相關裝置資訊

專案中需要新增system.management引用 1.在 解決方案資源管理器 視窗中 右擊專案 新增 引用 彈出引用管理器 2.在引用處理器中,程式集 框架 選中 system.management 確認 作業系統的登入使用者名稱 string getusername moc null mc n...