Что нового

Оптимизация отрезка скрипта

Talany

Знающий
Сообщения
136
Репутация
11
Доброго времени суток уважаемые пользователи AutoIt...
Есть отрезок кода
Код:
#include <Array.au3>
Global $wbemFlagReturnImmediately = 0x10, $wbemFlagForwardOnly = 0x20, $NetCard[1][1],  $ipadress, $NetInfo[1][1]
$objWMIService = ObjGet("winmgmts:\\" & @ComputerName & "\root\CIMV2")
 $get_network = $objWMIService.ExecQuery("SELECT Name,MACAddress,Manufacturer,Speed FROM Win32_NetworkAdapter WHERE NetConnectionStatus > 0", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
 If IsObj($get_network) Then 
    For $Property In $get_network
 	  ReDim $NetCard[$NetCard[0][0] + 1][9]
 	  $NetCard[$NetCard[0][0]][1] = $Property.MACAddress
	  $NetCard[$NetCard[0][0]][2] = $Property.Name
	  $NetCard[$NetCard[0][0]][3] = $Property.Speed /1000000
	  $NetCard[$NetCard[0][0]][4] = $Property.Manufacturer
	  $get_ip = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
	 For $p In $get_ip 
	 If $NetCard[$NetCard[0][0]][1] = $p.MACAddress Then
		$NetCard[$NetCard[0][0]][5] = $p.IpAddress(0)
		$NetCard[$NetCard[0][0]][6] = $p.IPSubnet(0)
		$NetCard[$NetCard[0][0]][7] = $p.DefaultIPGateway(0)
		$NetCard[$NetCard[0][0]][8] = $p.DNSServerSearchOrder(0)
	 EndIf
	 Next
 	  $NetCard[0][0] += 1
    Next
 EndIf
 _ArrayDisplay($NetCard)


Вопрос
Я знаю что написано АБЫКАК... Как бы вы его оптимизировали
P.S: И еще, выдает пустой результат в OC Windows Xp

Заранее благодарю.....
 

sngr

AutoIT Гуру
Сообщения
1,011
Репутация
409
Код:
#include <Array.au3>
Global $wbemFlagReturnImmediately = 0x10, $wbemFlagForwardOnly = 0x20, $NetCard[100][7], $j
$objWMIService = ObjGet("winmgmts:\\.\root\CIMV2")
$get_network = $objWMIService.ExecQuery("SELECT Name,MACAddress,Manufacturer,index " & _
"FROM Win32_NetworkAdapter WHERE NetConnectionStatus > 0", "WQL", $wbemFlagReturnImmediately _
		 + $wbemFlagForwardOnly)
For $Property In $get_network
	$NetCard[$j][0] = $Property.MACAddress
	$NetCard[$j][1] = $Property.Name
	$NetCard[$j][2] = $Property.Manufacturer
	$get_ip = $objWMIService.get("Win32_NetworkAdapterConfiguration.index=" & $Property.index)
	$NetCard[$j][3] = $get_ip.IpAddress(0)
	$NetCard[$j][4] = $get_ip.IPSubnet(0)
	$NetCard[$j][5] = $get_ip.DefaultIPGateway(0)
	$NetCard[$j][6] = $get_ip.DNSServerSearchOrder(0)
	$j += 1
Next

ReDim $NetCard[$j][7]
_ArrayDisplay($NetCard)
 
Автор
T

Talany

Знающий
Сообщения
136
Репутация
11
ХМММ! Даже так...
Благодарю sngr...
 
Верх