通過 獲取系統資訊

2021-08-02 18:27:30 字數 1106 閱讀 9341

通過wmi獲取網絡卡mac位址、硬碟序列號、主機板序列號、cpu id、bios序列號

delphi通過wmi獲取系統資訊

uses activex, comobj;

function getwmiproperty(wmitype, wmiproperty: string): string;

varwmi, objs, obj: olevariant;

enum: ienumvariant;

c: cardinal;

begin

wmi:= createoleobject('wbemscripting.swbemlocator');

objs := wmi.connectserver('.','root/cimv2').execquery('select * from win32_' + wmitype);

enum := ienumvariant(iunknown(objs._newenum));

enum.reset;

enum.next(1, obj, c);

obj := obj.properties_.item(wmiproperty, 0).value;

result := obj;

end;

// 獲取硬碟序列號

showmessage(getwmiproperty('diskdrive', 'pnpdeviceid'));

// 獲取biso序列號

showmessage(getwmiproperty('bios', 'serialnumber'));

// 獲取網絡卡mac位址

showmessage(getwmiproperty('networkadapter', 'macaddress'));

// 獲取網絡卡序列號

showmessage(getwmiproperty('networkadapter', 'pnpdeviceid'));

// 獲取cpu序列號

showmessage(getwmiproperty('processor', 'processorid'));

也可以用同樣的方法獲得任意感興趣的系統資訊,比如正在執行的程序、賬戶資訊等等。

更多wmi的資訊參考:

通過WMI獲取主機板資訊

using system using system.collections.generic using system.text using system.management namespace cs 列印主機板資訊 private static void printmotherboardinfo ...

系統資訊獲取 1,獲取系統版本

getversionex函式原型 cpp view plain copy bool getversionex posversioninfo pversioninformation 結構osversioninfoex定義如下 typedef struct osversioninfoex,posvers...

python 獲取系統資訊

學python,用rpa www.i search.com.cn index.html?from line1 python 是跨平台語言,有時候我們的程式需要執行在不同系統上,例如 linux macos windows,為了使程式有更好通用性,需要根據不同系統使用不同操作方式。我們可以使用 pla...