本帖最后由 solox 于 2009-8-7 23:54 编辑 Dim $MAC = Chr(13)
$strComputer = "localhost"
$objWMIService = ObjGet("winmgmts:\" & $strComputer & "\root\cimv2")
$colNicConfigs = $objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")
If IsObj($colNicConfigs) Then
For $objItem In $colNicConfigs
$objNic = $objWMIService.Get ("Win32_NetworkAdapter.DeviceID=" & $objItem.Index)
$MAC = $MAC & Chr(10) & $objNic.MACAddress
Next
$MAC = StringReplace($MAC,Chr(13)&Chr(10),"")
Else
SetError(1)
EndIf
MsgBox(0,"MAC",$MAC)
MsgBox(0, "共替换的数量为:", @extended)
这是一个读取本机MAC地址的程序,其中有两个语句不太了解作用
1、第一句的$MAC = Chr(13),为什么要先把$MAC设定成一个回车呢?
2、$MAC = StringReplace($MAC,Chr(13)&Chr(10),""),这一句的作用何在,调试发现它根本没替换任何字符呀? |