找回密码
 加入
搜索
查看: 2199|回复: 2

[系统综合] 二维数组赋值出错

[复制链接]
发表于 2011-9-26 01:12:16 | 显示全部楼层 |阅读模式
#RequireAdmin
#include <Array.au3>

$array = _GetMACAddress()
_ArrayDisplay($array)

Func _GetMACAddress()
Dim $array[5][2]
Dim $i=0
Local $wbemFlagReturnImmediately = 0x10
Local $wbemFlagForwardOnly = 0x20
Local $strComputer = "localhost"
Local $objWMIService,$colItems,$ret[2]

$objWMIService  = ObjGet("winmgmts:\" & $strComputer& "\root\cimv2")
$colItems = $objWMIService.ExecQuery("Select * From Win32_NetworkAdapter")

For $colItem In $colItems
    If $colItem.NetConnectionStatus = 2 Then
    $ret[$i][0] = $colItem.MACAddress
    $ret[$i][1] = $colItem.Name
        $i=$i+1
        EndIf        
Next
Return $ret
EndFunc
>运行:(3.3.6.1):E:\Program Files\autoit3\autoit3.exe "E:\Program Files\autoit3\SciTe\自动获取MAC\test3.au3"   
E:\Program Files\autoit3\SciTe\????MAC\test3.au3 (22) : ==> ?????????????.:
$ret[$i] = 1
^ ERROR
->01:11:01 AutoIT3.exe 完成:[CODE]:1
+>01:11:02 ACNWrapper 完成..
>退出代码: 1    时间: 3.835
 楼主| 发表于 2011-9-26 01:19:03 | 显示全部楼层
#RequireAdmin
#include <Array.au3>

$array = _GetMACAddress()
_ArrayDisplay($array)

Func _GetMACAddress()
Dim $ret[5][2]
Dim $i=0
Local $wbemFlagReturnImmediately = 0x10
Local $wbemFlagForwardOnly = 0x20
Local $strComputer = "localhost"
Local $objWMIService,$colItems,$ret[2]

$objWMIService  = ObjGet("winmgmts:\" & $strComputer& "\root\cimv2")
$colItems = $objWMIService.ExecQuery("Select * From Win32_NetworkAdapter")

For $colItem In $colItems
    If $colItem.NetConnectionStatus = 2 Then
    $ret[$i][0] = $colItem.MACAddress
    $ret[$i][1] = $colItem.Name
    $i=$i+1
    EndIf        
Next
Return $ret
EndFunc
刚刚的代码有个错误……
 楼主| 发表于 2011-9-26 03:12:39 | 显示全部楼层
已经发现错误改好了,原来是第13行多了一个定义
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-10 22:41 , Processed in 0.077390 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表