本文整理自网络,侵删。
单元:,ShlObj,ActiveX, ComObj
procedure GetAdapters;var oBindObj : IDispatch; oNetAdapters, oNetAdapter, odnsAddr, oWMIService : OleVariant; i, iValue : LongWord; oEnum : IEnumVariant; oCtx : IBindCtx; oMk : IMoniker; sFileObj : WideString;begin MainForm.sComboBox1.Items.Clear; sFileObj := 'winmgmts:\\.\root\cimv2';
OleCheck(CreateBindCtx(0,oCtx)); OleCheck(MkParseDisplayNameEx(oCtx, PWideChar(sFileObj), i, oMk)); OleCheck(oMk.BindToObject(oCtx, nil, IUnknown, oBindObj)); oWMIService := oBindObj;
oNetAdapters := oWMIService.ExecQuery('SE L EC T * FROM Win32_NetworkAdapter WHERE PhysicalAdapter=True AND MACAddress IS NOT NULL AND AdapterType IS NOT NULL');
oEnum := IUnknown(oNetAdapters._NewEnum) as IEnumVariant;
while oEnum.Next(1, oNetAdapter, iValue) = 0 do begin try MainForm.sCombobox1.Items.Add(oNetAdapter.Caption); except end;
oNetAdapter := Unassigned; end;
odnsAddr := Unassigned; oNetAdapters := Unassigned; oWMIService := Unassigned;end;
相关阅读 >>
Delphi tstringlist 保存txt文本文件最后一行不留空行
Delphi tstringlist的delimitedtext的空格问题
更多相关阅读请进入《Delphi》频道 >>