你对比一下看一看有什么地方不同:
#include <GuiIPAddress.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <IPAddressConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("IP", 213, 182, 193, 115)
$Group1 = GUICtrlCreateGroup("IP设置", 0, 0, 209, 177)
$IPAddress1 = _GUICtrlIpAddress_Create($Form1, 72, 24, 130, 21)
_GUICtrlIpAddress_Set($IPAddress1, "127.0.0.1")
$IPAddress2 = _GUICtrlIpAddress_Create($Form1, 72, 48, 130, 21)
_GUICtrlIpAddress_Set($IPAddress2, "255.255.255.0")
$IPAddress3 = _GUICtrlIpAddress_Create($Form1, 72, 72, 130, 21)
_GUICtrlIpAddress_Set($IPAddress3, "0.0.0.0")
$IPAddress4 = _GUICtrlIpAddress_Create($Form1, 72, 96, 130, 21)
_GUICtrlIpAddress_Set($IPAddress4, "0.0.0.0")
$IPAddress5 = _GUICtrlIpAddress_Create($Form1, 72, 120, 130, 21)
_GUICtrlIpAddress_Set($IPAddress5, "0.0.0.0")
$Label1 = GUICtrlCreateLabel(" I P 地 址:", 6, 24, 67, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label2 = GUICtrlCreateLabel("子网掩码:", 8, 48, 64, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label3 = GUICtrlCreateLabel("默认网关:", 9, 72, 64, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label4 = GUICtrlCreateLabel("首选DNS:", 6, 96, 69, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Label5 = GUICtrlCreateLabel("备用DNS:", 6, 120, 69, 20)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
$Button1 = GUICtrlCreateButton("确定", 72, 147, 59, 25, 0)
$Button2 = GUICtrlCreateButton("取消", 144, 147, 59, 25, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$strComputer = "."
Dim $SetIPAddress[1]
$SetIPAddress[0] = _GUICtrlIpAddress_Get($IPAddress1)
Dim $SetSubnetmask[1]
$SetSubnetmask[0] = _GUICtrlIpAddress_Get($IPAddress2)
Dim $SetGateway[1]
$SetGateway[0] = _GUICtrlIpAddress_Get($IPAddress3)
Dim $SetDns[2]
$SetDns[0] = _GUICtrlIpAddress_Get($IPAddress4)
$SetDns[1] = _GUICtrlIpAddress_Get($IPAddress5)
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = TRUE", "WQL", _
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
If IsObj($colItems) Then
For $objNetAdapter In $colItems
$objNetAdapter.EnableStatic($SetIPAddress, $SetSubnetmask)
$objNetAdapter.SetGateways($SetGateway)
$objNetAdapter.SetDNSServerSearchOrder($SetDns)
Next
MsgBox(64, "设置信息", $SetIPAddress[0] & @CRLF & $SetSubnetmask[0] & @CRLF & $SetGateway[0] & @CRLF & $SetDns)
EndIf
Case $Button2
Exit
EndSwitch
WEnd
|