Opt("MustDeclareVars", 1)
Opt("GUIResizeMode", 802)
Global $G_SZVERSION = "智能 IP 地址修改器 v3.1.0.10"
If WinExists($G_SZVERSION) Then Exit
AutoItWinSetTitle($G_SZVERSION)
If Not (IsDeclared("$cI_CompName")) Then Global $CI_COMPNAME = "localhost"
Global $WBEMFLAGRETURNIMMEDIATELY = 16, $WBEMFLAGFORWARDONLY = 32
Global $ERR_NO_INFO = "数组中找不到有效的信息", $ERR_NOT_OBJ = "$colItems 不是一个有效的对象"
Func _ERRORMSG($MESSAGE, $TIME = 0)
MsgBox(48 + 262144, "错误!", $MESSAGE, $TIME)
EndFunc ;==>_ERRORMSG
Global $ISHUTDOWN, $ICLEAN, $IREMOVE, $ILISTWAIT
If $CMDLINE[0] Then
For $I = 1 To $CMDLINE[0]
Select
Case StringRegExp($CMDLINE[$I], "^[/-](?i)AutoRun$")
$CMDLINERAW = StringReplace($CMDLINERAW, $CMDLINE[$I], "/isme")
Run(@AutoItExe & Chr(32) & $CMDLINERAW, @WorkingDir)
Exit
Case StringRegExp($CMDLINE[$I], "^[/-](?i)S$|^[/-](?i)ShutDown$")
$ISHUTDOWN = 1
Case StringRegExp($CMDLINE[$I], "^[/-](?i)C$|^[/-](?i)Clean$")
$ICLEAN = 1
Case StringRegExp($CMDLINE[$I], "^[/-](?i)R$|^[/-](?i)Remove$")
$IREMOVE = 1
Case StringRegExp($CMDLINE[$I], "^[/-](?i)ListWait[=:]\d+$|^[/-](?i)L[=:]\d+$")
$ILISTWAIT = StringRegExpReplace($CMDLINE[$I], "^[/-](?i)ListWait[=:]?|^[/-](?i)L[=:]?", "")
_SETTIMEOUT($ILISTWAIT)
EndSelect
Next
EndIf
If $ISHUTDOWN And MsgBox(308, "警告!", "是否把本程序添加到启用项并关机?") = 6 Then
_ADDRUNME($ICLEAN)
If $IREMOVE Then _REMOVEDEVICE()
If $ICLEAN Then _CLEANEVENT()
Shutdown(9)
Exit
EndIf
Global $NETINFO
_GETNETWORKNETINFO($NETINFO)
If Not $NETINFO[0][0] Then Exit
Global $ABOUTME = "33078632", $MACINFO = "Mac2Ip"
Global $INIFILE = @ScriptDir & "\AutoAdds.ini"
Global $PCNAME = @ComputerName
Global $SFUCK = "SURE"
Global $NUM, $IPREFIX, $IPOSTFIX, $IPFIX, $IOFFSET, $NUMLEN, $MACADD, $IPXADD, $IIPADD, $ISUBNET, $IGATEWAY, $IDNS1, $IDNS2
Global $MACENABLE, $IPXENABLE, $DHCPENABLE, $CDKENABLE
Global $IDFPATH, $IDFCMD, $DFENABLE, $ITIME, $INIT, $OVERTIME
Global $NAMEANDIP, $NETCONNECTIONNAME, $NETCARDNAME, $MOVELEN, $L
Global $SHOSTKEY = "{SPACE}"
Global $ACSCDK, $CS15CDK
If @Compiled Then
$ACSCDK = _RESOURCEGETASSTRING("CSCDK_TXT_1")
Else
$ACSCDK = FileRead("CSCDK.txt")
EndIf
$ACSCDK = StringSplit($ACSCDK, Chr(10))
$CS15CDK = $ACSCDK[Random(1, $ACSCDK[0], 1)]
If FileExists($INIFILE) Then
$IPREFIX = IniRead($INIFILE, $ABOUTME, "机名前缀", "")
$IPOSTFIX = IniRead($INIFILE, $ABOUTME, "机名后缀", "")
$IPFIX = IniRead($INIFILE, $ABOUTME, "IP前两位", "")
$IOFFSET = IniRead($INIFILE, $ABOUTME, "IP偏移值", "")
$NUMLEN = IniRead($INIFILE, $ABOUTME, "编号位数", "")
$ISUBNET = IniRead($INIFILE, $ABOUTME, "子网掩码", "")
$IGATEWAY = IniRead($INIFILE, $ABOUTME, "默认网关", "")
$IDNS1 = IniRead($INIFILE, $ABOUTME, "首选 DNS", "")
$IDNS2 = IniRead($INIFILE, $ABOUTME, "备用 DNS", "")
$MACENABLE = IniRead($INIFILE, $ABOUTME, "修改 MAC", "")
$IPXENABLE = IniRead($INIFILE, $ABOUTME, "修改 IPX", "")
$DHCPENABLE = IniRead($INIFILE, $ABOUTME, "使用DHCP", "")
$CDKENABLE = IniRead($INIFILE, $ABOUTME, "改 CSCDK", "")
$IDFPATH = IniRead($INIFILE, $ABOUTME, "调用程序", "")
$IDFCMD = IniRead($INIFILE, $ABOUTME, "程序参数", "")
$ITIME = IniRead($INIFILE, $ABOUTME, "倒计时", "")
$IPREFIX = _FIXSTRING($IPREFIX)
$IPOSTFIX = _FIXSTRING($IPOSTFIX, -1)
$IDFPATH = _GETFILEFULLPATH($IDFPATH)
EndIf
If Not StringIsDigit($NUMLEN) Then $NUMLEN = 3
If Not StringIsDigit($ITIME) Or Number($ITIME) < 5 Then $ITIME = 5
Global $H_POS[4] = [@DesktopWidth / 2 - 470 / 2, @DesktopHeight / 2 - 314 / 2, 450, 314]
Global $HGUI, $NMSG, $HSTATUSBAR, $GROUP1, $GROUP2, $COMBO1, $COMBO2, $CHECKBOX1, $CHECKBOX2, $CHECKBOX3, $CHECKBOX4
Global $BUTTON1, $BUTTON2, $BUTTON3, $BUTTON4, $LABEL1, $LABEL2, $LABEL3, $LABEL4, $HCS15CDK
Global $INPUT1, $HIPADD1, $HIPADD2, $HIPADD3, $HIPADD4, $HIPADD5, $HMACADD, $HIPXADD
ADLIBENABLE("_KillPop")
_MAIN()
Func _MAIN()
Local $I
$HGUI = GUICreate($G_SZVERSION, $H_POS[2], $H_POS[3], $H_POS[0], $H_POS[1], BitOR($WS_CAPTION, $WS_SYSMENU))
GUISetIcon("shell32.dll", 268)
$HSTATUSBAR = _GUICtrlStatusBar_Create($HGUI, -1, "")
Local $HICONS[2]
Local $APARTS[2] = [$H_POS[2] - 93, -1]
_GUICtrlStatusBar_SetParts($HSTATUSBAR, $APARTS)
_GUICtrlStatusBar_SetText($HSTATUSBAR, $G_SZVERSION)
_GUICtrlStatusBar_SetText($HSTATUSBAR, "Make By Amu", 1)
$HICONS[0] = _WinAPI_LoadShell32Icon(221)
$HICONS[1] = _WinAPI_LoadShell32Icon(160)
_GUICtrlStatusBar_SetIcon($HSTATUSBAR, 0, $HICONS[0])
_GUICtrlStatusBar_SetIcon($HSTATUSBAR, 1, $HICONS[1])
Local $XY[2] = [22, 26]
$GROUP1 = GUICtrlCreateGroup("基本信息", $XY[0] - 15, $XY[1] - 20, $H_POS[2] - 14, 132)
GUICtrlCreateLabel("网络适配器(&S):", $XY[0], $XY[1], 81, 18, $SS_LEFT + $SS_CENTERIMAGE)
$COMBO1 = GUICtrlCreateCombo($NETINFO[$NETINFO[0][0]][3], $XY[0] + 81 + 5, $XY[1], 320, 18, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
For $I = 1 To $NETINFO[0][0]
GUICtrlSetData($COMBO1, $NETINFO[$I][3])
Next
GUICtrlCreateLabel("计算机名(&N):", $XY[0], $XY[1] + 28, 70, 18, $SS_LEFT + $SS_CENTERIMAGE)
$INPUT1 = GUICtrlCreateInput(@ComputerName, $XY[0] + 80 + 5, $XY[1] + 28, 178, 18, $SS_CENTER)
GUICtrlSetTip(-1, "请输入纯数字")
$HCS15CDK = GUICtrlCreateLabel("偏移值(&F):", $XY[0] + 80 + 5 + 80 + 120, $XY[1] + 28, 61, 18, $SS_CENTERIMAGE)
$COMBO2 = GUICtrlCreateInput("0", $XY[0] + 80 + 5 + 80 + 120 + 61 + 5, $XY[1] + 28, 55, 18, $ES_NUMBER + $ES_CENTER, $WS_EX_CLIENTEDGE)
GUICtrlSetState(-1, $GUI_DISABLE)
If Number($IOFFSET) Then GUICtrlSetData(-1, $IOFFSET)
GUICtrlSetLimit($COMBO2, 5, 1)
GUICtrlCreateUpdown($COMBO2, $UDS_ARROWKEYS + $UDS_NOTHOUSANDS)
GUICtrlSetLimit(-1, 32767, 0)
$CHECKBOX1 = GUICtrlCreateCheckbox("安装 DeepFreeze 保护软件(&B)", $XY[0] + 5, $XY[1] + 28 * 2, 240, 18)
If StringLower(RegRead("HKLM\SYSTEM\CurrentControlSet\Services\DeepFrz", "DisplayName")) = "deepfrz" Then
GUICtrlSetState(-1, 129)
GUICtrlSetData(-1, "本机貌似已安装 DeepFreeze 保护软件")
ElseIf FileExists($IDFPATH) Then
GUICtrlSetState(-1, 1)
Else
GUICtrlSetState(-1, 132)
GUICtrlSetData(-1, "找不到 DeepFreeze 保护软件安装程序")
EndIf
$CHECKBOX2 = GUICtrlCreateCheckbox("从 DHCP 获得 IP 地址(&H)", $XY[0] + 250, $XY[1] + 28 * 2, 160, 18)
$CHECKBOX3 = GUICtrlCreateCheckbox("修改 IPX 内部网络号(&T):", $XY[0] + 5, $XY[1] + 28 * 3, 160, 18)
$HIPXADD = GUICtrlCreateInput($NETINFO[$NETINFO[0][0]][9], $XY[0] + 165, $XY[1] + 28 * 3, 60, 18, $ES_NUMBER + $SS_CENTER)
GUICtrlSetLimit(-1, 8)
GUICtrlSetTip(-1, "请输入十进制数字")
$CHECKBOX4 = GUICtrlCreateCheckbox("修改 MAC 地址(&W)", $XY[0] + 250, $XY[1] + 28 * 3, 120, 18)
GUICtrlSetTip(-1, "暂时不支持修改 MAC 地址")
If $DHCPENABLE = "是" Then GUICtrlSetState($CHECKBOX2, 1)
$BUTTON1 = GUICtrlCreateCheckbox("使用手动输入的 IP 地址(&Q)", $XY[0] - 14, $XY[1] + 28 * 3 + 10 + 140, 160, 20, $BS_PUSHLIKE)
$BUTTON2 = GUICtrlCreateButton("配置(&O)", $XY[0] - 14 + 180 + 5, $XY[1] + 28 * 3 + 10 + 140, 60, 20)
$BUTTON3 = GUICtrlCreateButton("修改(&Z)", $XY[0] - 14 + 180 + 25 + 60 + 25, $XY[1] + 28 * 3 + 10 + 140, 60, 20)
$BUTTON4 = GUICtrlCreateButton("取消(&C)", 381, $XY[1] + 28 * 3 + 10 + 140, 60, 20)
Local $BS[2] = [$XY[0], $XY[1] + 28 * 5]
$GROUP2 = GUICtrlCreateGroup("", $BS[0] - 15, $BS[1] - 24, $H_POS[2] - 14, 110)
$LABEL1 = GUICtrlCreateLabel("MAC 地址(&M):", $BS[0] + 200 + 10, $BS[1], 70, 18, $SS_LEFT + $SS_CENTERIMAGE)
$HMACADD = GUICtrlCreateInput("", $BS[0] + 280 + 5, $BS[1], 120, 18)
GUICtrlSetStyle(-1, $SS_CENTER + $ES_READONLY)
GUICtrlSetData($HMACADD, $NETINFO[$NETINFO[0][0]][2])
If GUICtrlRead($CHECKBOX4) = 4 Then GUICtrlSetState($HMACADD, $GUI_DISABLE)
$LABEL2 = GUICtrlCreateLabel("IP 地址(&I):", $BS[0], $BS[1], 72, 18, $SS_RIGHT + $SS_CENTERIMAGE)
$HIPADD1 = _GUICtrlIpAddress_Create($HGUI, $BS[0] + 70 + 5, $BS[1], 120, 18)
_GUICtrlIpAddress_Set($HIPADD1, @IPAddress1)
GUICtrlCreateLabel("子网掩码(&U):", $BS[0], $BS[1] + 26, 70, 18, $SS_LEFT + $SS_CENTERIMAGE)
$HIPADD2 = _GUICtrlIpAddress_Create($HGUI, $BS[0] + 70 + 5, $BS[1] + 26, 120, 18)
_GUICtrlIpAddress_Set($HIPADD2, $ISUBNET)
$LABEL3 = GUICtrlCreateLabel("默认网关(&D):", $BS[0] + 200 + 10, $BS[1] + 26, 70, 18, $SS_LEFT + $SS_CENTERIMAGE)
$HIPADD3 = _GUICtrlIpAddress_Create($HGUI, $BS[0] + 280 + 5, $BS[1] + 26, 120, 18)
_GUICtrlIpAddress_Set($HIPADD3, $IGATEWAY)
$LABEL4 = GUICtrlCreateLabel("首选 DNS(&P):", $BS[0], $BS[1] + 26 * 2, 70, 18, $SS_LEFT + $SS_CENTERIMAGE)
$HIPADD4 = _GUICtrlIpAddress_Create($HGUI, $BS[0] + 70 + 5, $BS[1] + 26 * 2, 120, 18)
_GUICtrlIpAddress_Set($HIPADD4, $IDNS1)
GUICtrlCreateLabel("备用 DNS(&A):", $BS[0] + 200 + 10, $BS[1] + 26 * 2, 70, 18, $SS_LEFT + $SS_CENTERIMAGE)
$HIPADD5 = _GUICtrlIpAddress_Create($HGUI, $BS[0] + 280 + 5, $BS[1] + 26 * 2, 120, 18)
_GUICtrlIpAddress_Set($HIPADD5, $IDNS2)
GUISetState(@SW_SHOW)
_HGUIUPDATE()
While 1
$NMSG = GUIGetMsg()
Select
Case $NMSG = $GUI_EVENT_CLOSE Or $NMSG = $BUTTON4
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $HGUI, "int", 100, "long", 65552)
ExitLoop
Case $NMSG = $COMBO1 Or $NMSG = $CHECKBOX2
_HGUIUPDATE()
Case $NMSG = $CHECKBOX3
Switch GUICtrlRead($CHECKBOX3)
Case 1
GUICtrlSetState($HIPXADD, $GUI_ENABLE)
If GUICtrlRead($BUTTON1) = 1 Then
GUICtrlSetStyle($HIPXADD, $ES_CENTER + $ES_READONLY)
Else
GUICtrlSetStyle($HIPXADD, $ES_NUMBER + $ES_CENTER)
EndIf
Case Else
GUICtrlSetStyle($HIPXADD, $ES_CENTER + $ES_READONLY)
If GUICtrlRead($BUTTON1) = 1 Then GUICtrlSetState($HIPXADD, $GUI_DISABLE)
EndSwitch
Case $NMSG = $CHECKBOX4
Switch GUICtrlRead($CHECKBOX4)
Case 1
GUICtrlSetState($HMACADD, $GUI_ENABLE)
Case Else
GUICtrlSetState($HMACADD, $GUI_DISABLE)
EndSwitch
Case $NMSG = $BUTTON1
_STOP()
Case $NMSG = $HCS15CDK
$CS15CDK = $ACSCDK[Random(1, $ACSCDK[0], 1)]
If $CS15CDK And $CDKENABLE <> "否" Then GUICtrlSetTip($HCS15CDK, "呵呵!给你发现了,以下是CS1.5将要用到的CDKEY:" & $CS15CDK)
Case $NMSG = $BUTTON2
HotKeySet($SHOSTKEY)
_CONFIGWIN()
If $INIT Then _HGUIUPDATE()
Case $NMSG = $BUTTON3
$INIT = 0
$NETCARDNAME = GUICtrlRead($COMBO1)
$PCNAME = GUICtrlRead($INPUT1)
$DFENABLE = GUICtrlRead($CHECKBOX1)
$DHCPENABLE = GUICtrlRead($CHECKBOX2)
$IPXENABLE = GUICtrlRead($CHECKBOX3)
$MACENABLE = GUICtrlRead($CHECKBOX4)
$IPXADD = GUICtrlRead($HIPXADD)
$MACADD = GUICtrlRead($HMACADD)
$IIPADD = _GUICtrlIpAddress_Get($HIPADD1)
$ISUBNET = _GUICtrlIpAddress_Get($HIPADD2)
$IGATEWAY = _GUICtrlIpAddress_Get($HIPADD3)
$IDNS1 = _GUICtrlIpAddress_Get($HIPADD4)
$IDNS2 = _GUICtrlIpAddress_Get($HIPADD5)
_GUICtrlStatusBar_SetText($HSTATUSBAR, "正在修改“" & $NETCONNECTIONNAME & "”的 IP 设置...")
If $DHCPENABLE = 1 Then
_WMI_SETNETWORKADAPTERINFO($NETCARDNAME, $PCNAME, $DHCPENABLE)
Else
_WMI_SETNETWORKADAPTERINFO($NETCARDNAME, $PCNAME, 0, $IIPADD, $ISUBNET, $IGATEWAY, $IDNS1 & "," & $IDNS2, $IPXADD)
EndIf
_GUICtrlStatusBar_SetText($HSTATUSBAR, "“" & $NETCONNECTIONNAME & "”的 IP 修改完毕!")
If $CS15CDK And $CDKENABLE <> "否" Then RegWrite("HKCU\Software\Valve\CounterStrike\Settings", "key", "REG_SZ", String($CS15CDK))
If $DFENABLE = 1 And GUICtrlGetState($CHECKBOX1) = 80 Then
_GUICtrlStatusBar_SetText($HSTATUSBAR, "找到DeepFreeze 保护软件,准备安装 !")
Run($IDFPATH & Chr(32) & $IDFCMD)
If $ICLEAN Then _CLEANEVENT()
ControlClick($HGUI, "", $BUTTON4)
ElseIf MsgBox(308, "警告!", "是否马上重新启动计算机?") = 6 Then
MsgBox(308, "测试", "Shutdown(2) 重启!")
EndIf
_GETNETWORKNETINFO($NETINFO)
Case Else
If $INIT Then
If $OVERTIME = $ITIME - Int(TimerDiff($INIT) / 1000) Then ContinueLoop
$OVERTIME = $ITIME - Int(TimerDiff($INIT) / 1000)
If $OVERTIME >= 0 Then
_GUICtrlStatusBar_SetText($HSTATUSBAR, "找到本机 IP 配置信息并在 " & $OVERTIME & " 秒后自动修改(按空格键取消)!")
Else
ControlClick($HGUI, "", $BUTTON3)
EndIf
ElseIf GUICtrlRead($BUTTON1) = 1 And GUICtrlRead($CHECKBOX2) = 4 And (GUICtrlRead($INPUT1) <> $PCNAME Or GUICtrlRead($COMBO2) <> $IOFFSET) Then
$IOFFSET = GUICtrlRead($COMBO2)
$NUM = _GETFIRSTNUMFROMTEXT(GUICtrlRead($INPUT1), $NUMLEN)
$IPXADD = StringFormat("%08d", $NUM)
$PCNAME = $IPREFIX & $NUM & $IPOSTFIX
$IIPADD = _GETADDFORMNUMPREFIXOFFSET($NUM, $IPFIX, $IOFFSET)
GUICtrlSetData($INPUT1, $PCNAME)
GUICtrlSetData($HIPXADD, $IPXADD)
_GUICtrlIpAddress_Set($HIPADD1, $IIPADD)
$MOVELEN = StringInStr($PCNAME, $IPOSTFIX)
If $MOVELEN Then _GUICtrlEdit_SetSel($INPUT1, $MOVELEN - 1, $MOVELEN - 1)
EndIf
EndSelect
WEnd
EndFunc ;==>_MAIN
Func _CONFIGWIN()
$IOFFSET = GUICtrlRead($COMBO2)
$ISUBNET = _GUICtrlIpAddress_Get($HIPADD2)
$IGATEWAY = _GUICtrlIpAddress_Get($HIPADD3)
$IDNS1 = _GUICtrlIpAddress_Get($HIPADD4)
$IDNS2 = _GUICtrlIpAddress_Get($HIPADD5)
If Not $IPFIX Then $IPFIX = StringLeft($IGATEWAY, StringInStr($IGATEWAY, ".", 0, 2) - 1)
Local $NIP, $NMAC, $NHOST
Local $NGUI, $MMSG, $HLISTVIEW, $PIC1, $SCANMACSHOW, $I
Local $INPUT[7], $CHECKBOX[3], $IPADD[6], $BUTTON[5], $AIP0, $AIP1
Local $XY[2] = [18, 26]
Local $N_POS = WinGetPos($HGUI)
$NGUI = GUICreate("配置", $N_POS[2] - 25, $N_POS[3] - 66, $N_POS[0] + 22, $N_POS[1] + 22, BitOR($WS_CAPTION, $WS_SYSMENU), $WS_EX_CONTEXTHELP, $HGUI)
GUICtrlCreateGroup("基本设置", $XY[0] - 11, $XY[1] - 20, 410, $XY[1] + 28 * 4 + 8)
GUICtrlCreateLabel("机名前缀:", $XY[0], $XY[1], 55, 18, $SS_LEFT + $SS_CENTERIMAGE)
$INPUT[0] = GUICtrlCreateInput($IPREFIX, $XY[0] + 55 + 5, $XY[1], 80, 18, $SS_CENTER)
GUICtrlCreateLabel("机名后缀:", $XY[0] + 55 + 5 + 80 + 10, $XY[1], 55, 18, $SS_LEFT + $SS_CENTERIMAGE)
$INPUT[1] = GUICtrlCreateInput($IPOSTFIX, $XY[0] + 55 * 2 + 5 * 2 + 80 + 10, $XY[1], 60, 18, $SS_CENTER)
GUICtrlCreateLabel("偏移值:", $XY[0] + 55 * 2 + 5 * 2 + 80 + 10 + 70, $XY[1], 41, 18, $SS_LEFT + $SS_CENTERIMAGE)
$INPUT[2] = GUICtrlCreateInput($IOFFSET, $XY[0] + 55 * 2 + 5 * 2 + 80 + 10 + 70 + 41 + 5, $XY[1], 55, 18, $ES_NUMBER + $ES_CENTER, $WS_EX_CLIENTEDGE)
GUICtrlSetLimit(-1, 5, 1)
GUICtrlCreateUpdown(-1, $UDS_ARROWKEYS + $UDS_NOTHOUSANDS)
GUICtrlSetLimit(-1, 32767, 0)
GUICtrlCreateLabel("IP前两位:", $XY[0], $XY[1] + 28, 55, 18, $SS_LEFT + $SS_CENTERIMAGE)
$INPUT[3] = GUICtrlCreateInput($IPFIX, $XY[0] + 55 + 5, $XY[1] + 28, 55, 18, $SS_CENTER)
GUICtrlCreateGroup("", 142, $XY[1] + 20, 257, 28)
$CHECKBOX[0] = GUICtrlCreateCheckbox("改IPX编号", 150, $XY[1] + 29, 70, 17, $BS_RIGHTBUTTON)
GUICtrlSetState(-1, 1)
$CHECKBOX[1] = GUICtrlCreateCheckbox("改MAC地址", 230, $XY[1] + 29, 70, 17, $BS_RIGHTBUTTON)
$CHECKBOX[2] = GUICtrlCreateCheckbox("使用DHCP", 323, $XY[1] + 29, 65, 17, $BS_RIGHTBUTTON)
GUICtrlCreateLabel("子网掩码:", $XY[0], $XY[1] + 28 * 2 + 8, 55, 18, $SS_LEFT + $SS_CENTERIMAGE)
$IPADD[0] = _GUICtrlIpAddress_Create($NGUI, $XY[0] + 55 + 5, $XY[1] + 28 * 2 + 8, 120, 18)
_GUICtrlIpAddress_Set($IPADD[0], $ISUBNET)
GUICtrlCreateLabel("默认网关:", $XY[0] + 55 + 5 + 140, $XY[1] + 28 * 2 + 8, 55, 18, $SS_LEFT + $SS_CENTERIMAGE)
$IPADD[1] = _GUICtrlIpAddress_Create($NGUI, $XY[0] + 55 * 2 + 5 * 2 + 140, $XY[1] + 28 * 2 + 8, 120, 18)
_GUICtrlIpAddress_Set($IPADD[1], $IGATEWAY)
GUICtrlCreateLabel("首选 DNS:", $XY[0], $XY[1] + 28 * 3 + 8, 55, 18, $SS_LEFT + $SS_CENTERIMAGE)
$IPADD[2] = _GUICtrlIpAddress_Create($NGUI, $XY[0] + 55 + 5, $XY[1] + 28 * 3 + 8, 120, 18)
_GUICtrlIpAddress_Set($IPADD[2], $IDNS1)
GUICtrlCreateLabel("备用 DNS:", $XY[0] + 55 + 5 + 140, $XY[1] + 28 * 3 + 8, 55, 18, $SS_LEFT + $SS_CENTERIMAGE)
$IPADD[3] = _GUICtrlIpAddress_Create($NGUI, $XY[0] + 55 * 2 + 5 * 2 + 140, $XY[1] + 28 * 3 + 8, 120, 18)
_GUICtrlIpAddress_Set($IPADD[3], $IDNS2)
$XY[1] = 174
GUICtrlCreateGroup("", $XY[0] - 11, $XY[1] - 20, 410, 82)
GUICtrlCreateLabel("调用程序:", $XY[0], $XY[1], 55, 18, $SS_LEFT + $SS_CENTERIMAGE)
$INPUT[4] = GUICtrlCreateInput($IDFPATH, $XY[0] + 55 + 5, $XY[1], 240, 18)
$BUTTON[0] = GUICtrlCreateButton("浏览(&B)...", 330, $XY[1] - 1, 70, 20)
GUICtrlCreateLabel("程序参数:", $XY[0], $XY[1] + 28, 55, 18, $SS_LEFT + $SS_CENTERIMAGE)
$INPUT[5] = GUICtrlCreateInput($IDFCMD, $XY[0] + 55 + 5, $XY[1] + 28, 210, 18)
GUICtrlSetTip(-1, $IDFCMD)
GUICtrlCreateLabel("倒计时:", 300, $XY[1] + 28, 41, 18, $SS_LEFT + $SS_CENTERIMAGE)
GUICtrlCreateLabel("秒", 300 + 82 + 6, $XY[1] + 28, 16, 18, $SS_LEFT + $SS_CENTERIMAGE)
$INPUT[6] = GUICtrlCreateInput($ITIME, 300 + 41 + 3, $XY[1] + 28, 41, 18, $ES_NUMBER + $ES_CENTER, $WS_EX_CLIENTEDGE)
GUICtrlSetLimit(-1, 3, 1)
GUICtrlCreateUpdown(-1, $UDS_ARROWKEYS + $UDS_NOTHOUSANDS)
GUICtrlSetLimit(-1, 999, 5)
$XY[1] = 245
$BUTTON[1] = GUICtrlCreateButton("取消(&C)", $XY[0] + 20, $XY[1], 55, 20)
$BUTTON[2] = GUICtrlCreateButton("保存(&Z)", $XY[0] + 100, $XY[1], 55, 20)
$BUTTON[3] = GUICtrlCreateButton("扫描 MAC 地址(&E)", $XY[0] + 255, $XY[1], 110, 20, $BS_PUSHLIKE)
$XY[1] = 300
GUIStartGroup()
GUICtrlCreateGroup("扫描 MAC 地址", $XY[0] - 11, $XY[1] - 20, 410, 190)
GUICtrlCreateLabel("从", $XY[0] + 3, $XY[1], 16, 18, $SS_LEFT + $SS_CENTERIMAGE)
$IPADD[4] = _GUICtrlIpAddress_Create($NGUI, $XY[0] + 18, $XY[1], 120, 18)
GUICtrlCreateLabel("到", $XY[0] + 141, $XY[1], 16, 18, $SS_LEFT + $SS_CENTERIMAGE)
$IPADD[5] = _GUICtrlIpAddress_Create($NGUI, $XY[0] + 156, $XY[1], 120, 18)
$BUTTON[4] = GUICtrlCreateCheckbox("扫描(&S)", $XY[0] + 310, $XY[1] - 1, 55, 20, $BS_PUSHLIKE)
GUICtrlSetState(-1, $GUI_DISABLE)
$HLISTVIEW = GUICtrlCreateListView("MAC 地址|计算机名|IP地址", $XY[0] + 3, $XY[1] + 28, 380, 130)
_GUICtrlListView_SetColumnWidth($HLISTVIEW, 0, 140)
_GUICtrlListView_SetColumnWidth($HLISTVIEW, 1, 120)
GUISetState(@SW_SHOW)
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $HGUI, "int", 500, "long", 589824)
While 1
$MMSG = GUIGetMsg(1)
$AIP0 = _GUICtrlIpAddress_GetArray($IPADD[4])
$AIP1 = _GUICtrlIpAddress_GetArray($IPADD[5])
Select
Case $MMSG[0] = $GUI_EVENT_CLOSE
Switch $MMSG[1]
Case $NGUI
ExitLoop
Case $HGUI
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $NGUI, "int", 100, "long", 65538)
GUIDelete($NGUI)
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $HGUI, "int", 100, "long", 65552)
GUIDelete($HGUI)
Exit
EndSwitch
Case $MMSG[0] = $BUTTON[0]
$IDFPATH = FileOpenDialog("请选择要调用的程序", "", "程序(*.exe;*.com)", 1, "DF6Wks.exe")
If Not @error Then GUICtrlSetData($INPUT[4], $IDFPATH)
Case $MMSG[0] = $BUTTON[1]
ExitLoop
Case $MMSG[0] = $BUTTON[2]
$IPREFIX = GUICtrlRead($INPUT[0])
$IPOSTFIX = GUICtrlRead($INPUT[1])
$IOFFSET = GUICtrlRead($INPUT[2])
$IPFIX = GUICtrlRead($INPUT[3])
$ISUBNET = _GUICtrlIpAddress_Get($IPADD[0])
$IGATEWAY = _GUICtrlIpAddress_Get($IPADD[1])
$IDNS1 = _GUICtrlIpAddress_Get($IPADD[2])
$IDNS2 = _GUICtrlIpAddress_Get($IPADD[3])
$IPXENABLE = GUICtrlRead($CHECKBOX[0])
$MACENABLE = GUICtrlRead($CHECKBOX[1])
$DHCPENABLE = GUICtrlRead($CHECKBOX[2])
$IDFPATH = GUICtrlRead($INPUT[4])
$IDFCMD = GUICtrlRead($INPUT[5])
$ITIME = GUICtrlRead($INPUT[6])
$IPREFIX = _FIXSTRING($IPREFIX)
$IPOSTFIX = _FIXSTRING($IPOSTFIX, -1)
IniWrite($INIFILE, $ABOUTME, "机名前缀", $IPREFIX)
IniWrite($INIFILE, $ABOUTME, "机名后缀", $IPOSTFIX)
IniWrite($INIFILE, $ABOUTME, "IP前两位", $IPFIX)
IniWrite($INIFILE, $ABOUTME, "IP偏移值", $IOFFSET)
IniWrite($INIFILE, $ABOUTME, "子网掩码", $ISUBNET)
IniWrite($INIFILE, $ABOUTME, "默认网关", $IGATEWAY)
IniWrite($INIFILE, $ABOUTME, "首选 DNS", $IDNS1)
IniWrite($INIFILE, $ABOUTME, "备用 DNS", $IDNS2)
IniWrite($INIFILE, $ABOUTME, "修改 MAC", "否")
If $MACENABLE = 1 Then
IniWrite($INIFILE, $ABOUTME, "修改 MAC", "是")
Else
IniWrite($INIFILE, $ABOUTME, "修改 MAC", "否")
EndIf
If $IPXENABLE = 1 Then
IniWrite($INIFILE, $ABOUTME, "修改 IPX", "是")
Else
IniWrite($INIFILE, $ABOUTME, "修改 IPX", "否")
EndIf
If $DHCPENABLE = 1 Then
IniWrite($INIFILE, $ABOUTME, "使用DHCP", "是")
Else
IniWrite($INIFILE, $ABOUTME, "使用DHCP", "否")
EndIf
IniWrite($INIFILE, $ABOUTME, "改 CSCDK", "否")
IniWrite($INIFILE, $ABOUTME, "调用程序", $IDFPATH)
IniWrite($INIFILE, $ABOUTME, "程序参数", $IDFCMD)
IniWrite($INIFILE, $ABOUTME, "倒计时", $ITIME)
MsgBox(64, "提示", "保存完成!")
Case $MMSG[0] = $BUTTON[3]
Local $N_POS = WinGetPos($NGUI)
Local $D_POS = ControlGetPos("Program Manager", "FolderView", "SysListView321")
Switch $SCANMACSHOW
Case 1
WinMove($NGUI, "", $N_POS[0], $N_POS[1], $N_POS[2], $N_POS[3] - 205)
GUICtrlSetState($BUTTON[4], $GUI_DISABLE)
$SCANMACSHOW = 0
Case Else
GUICtrlSetState($BUTTON[4], $GUI_ENABLE)
If $N_POS[1] > $D_POS[3] - $N_POS[3] - 205 Then $N_POS[1] = $D_POS[3] - $N_POS[3] - 205
WinMove($NGUI, "", $N_POS[0], $N_POS[1], $N_POS[2], $N_POS[3] + 205)
$SCANMACSHOW = 1
EndSwitch
Case $MMSG[0] = $BUTTON[4]
Switch GUICtrlRead($BUTTON[4])
Case 1
TCPStartup()
Local $ISTEP = 1
If $AIP0[3] > $AIP1[3] Then $ISTEP = -1
For $I = $AIP0[3] To $AIP1[3] Step $ISTEP
$NIP = $AIP0[0] & "." & $AIP0[1] & "." & $AIP0[2] & "." & $I
Ping($NIP, 5)
If @error Then ContinueLoop
$NHOST = _TCPIpToName($NIP)
$NMAC = _API_GET_NETWORKADAPTERMAC($NIP)
GUICtrlCreateListViewItem($NMAC & "|" & $NHOST & "|" & $NIP, $HLISTVIEW)
IniWrite($INIFILE, $MACINFO, $NMAC, $NHOST & "|" & $NIP)
Next
ControlClick($NGUI, "", $BUTTON[4])
Case Else
EndSwitch
Case Else
For $I = 0 To 2
If $AIP1[$I] >= $AIP0[$I] Then ContinueLoop
$AIP1[$I] = $AIP0[$I]
_GUICtrlIpAddress_SetArray($IPADD[5], $AIP1)
Next
EndSelect
WEnd
$N_POS = WinGetPos($NGUI)
WinMove($HGUI, "", $N_POS[0] - 22, $N_POS[1] - 22)
DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $HGUI, "int", 500, "long", 524288)
GUIDelete($NGUI)
WinActivate($HGUI)
EndFunc ;==>_CONFIGWIN
Func _HGUIUPDATE()
$L = _VERGETARRAY($NETINFO, GUICtrlRead($COMBO1))
If @error Then Return 0
$NETCONNECTIONNAME = $NETINFO[$L][1]
Local $LMACADD = $NETINFO[$L][2]
Local $LIPXADD = $NETINFO[$L][9]
Local $LIPADD = $NETINFO[$L][4]
Local $LSUBNET = $NETINFO[$L][5]
Local $LGATEWAY = $NETINFO[$L][6]
Local $LDNS1 = $NETINFO[$L][7]
Local $LDNS2 = $NETINFO[$L][8]
If Not $IPREFIX Then
$IPREFIX = _GETFIRSTLETTERFROMTEXT(GUICtrlRead($INPUT1))
$IPOSTFIX = _GETFIRSTLETTERFROMTEXT(GUICtrlRead($INPUT1), -1)
EndIf
GUICtrlSetData($GROUP2, $NETCONNECTIONNAME & " =>> Internet 协议 (TCP/IP) 属性")
GUICtrlSetData($HIPXADD, $LIPXADD)
GUICtrlSetData($HMACADD, $LMACADD)
_GUICtrlIpAddress_Set($HIPADD1, $LIPADD)
_GUICtrlIpAddress_Set($HIPADD2, $LSUBNET)
_GUICtrlIpAddress_Set($HIPADD3, $LGATEWAY)
_GUICtrlIpAddress_Set($HIPADD4, $LDNS1)
_GUICtrlIpAddress_Set($HIPADD5, $LDNS2)
_SETIPEDITSTATE(0)
If GUICtrlRead($CHECKBOX2) = 1 Then
$INIT = 0
_GUICtrlStatusBar_SetText($HSTATUSBAR, "输入计算机名,并从 DHCP 服务器获得 IP 地址!")
GUICtrlSetData($LABEL1, "DHCP 服务器:")
GUICtrlSetData($HMACADD, "等待获取DHCP服务器")
GUICtrlSetState($BUTTON1, $GUI_DISABLE)
GUICtrlSetState($HIPXADD, $GUI_DISABLE)
GUICtrlSetState($CHECKBOX3, 132)
GUICtrlSetState($CHECKBOX4, 132)
GUICtrlSetState($HMACADD, $GUI_DISABLE)
ControlClick($HGUI, "", $INPUT1)
_GUICtrlEdit_SetSel($INPUT1, 0, StringLen(GUICtrlRead($INPUT1)))
Else
GUICtrlSetData($LABEL1, "MAC 地址(&M):")
GUICtrlSetState($BUTTON1, $GUI_ENABLE)
If $IPXENABLE <> "否" Then GUICtrlSetState($CHECKBOX3, 1)
$NAMEANDIP = IniRead($INIFILE, $MACINFO, $LMACADD, "")
If $NAMEANDIP And Not $INIT Then
_GUICtrlStatusBar_SetText($HSTATUSBAR, "找到本机 IP 配置信息!")
$NAMEANDIP = StringSplit($NAMEANDIP, "|")
If $NAMEANDIP[0] <> 2 Then
$PCNAME = GUICtrlRead($INPUT1)
$IIPADD = _GUICtrlIpAddress_Get($HIPADD1)
Else
$PCNAME = $NAMEANDIP[1]
$IIPADD = $NAMEANDIP[2]
GUICtrlSetState($INPUT1, $GUI_DISABLE)
GUICtrlSetState($COMBO2, $GUI_DISABLE)
GUICtrlSetState($HIPXADD, $GUI_DISABLE)
GUICtrlSetState($CHECKBOX3, 128)
GUICtrlSetState($CHECKBOX4, 132)
GUICtrlSetState($HMACADD, $GUI_DISABLE)
EndIf
$LIPXADD = _GETFIRSTNUMFROMTEXT($PCNAME, $NUMLEN)
$LIPXADD = StringFormat("%08d", $LIPXADD)
GUICtrlSetData($INPUT1, $PCNAME)
GUICtrlSetData($HIPXADD, $LIPXADD)
GUICtrlSetData($HMACADD, $LMACADD)
If $IIPADD <> $LIPADD And StringRegExp($IIPADD, "((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)") Then
_GUICtrlIpAddress_Set($HIPADD1, $IIPADD)
$INIT = -1
EndIf
If $ISUBNET <> $LSUBNET And StringRegExp($ISUBNET, "((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)") Then
_GUICtrlIpAddress_Set($HIPADD2, $ISUBNET)
$INIT = -1
EndIf
If $IGATEWAY <> $LGATEWAY And StringRegExp($IGATEWAY, "((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)") Then
_GUICtrlIpAddress_Set($HIPADD3, $IGATEWAY)
$INIT = -1
EndIf
If $IDNS1 <> $LDNS1 And StringRegExp($IDNS1, "((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)") Then
_GUICtrlIpAddress_Set($HIPADD4, $IDNS1)
$INIT = -1
EndIf
If $IDNS1 <> $LDNS1 And StringRegExp($IDNS1, "((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)") Then
_GUICtrlIpAddress_Set($HIPADD5, $IDNS2)
$INIT = -1
EndIf
If GUICtrlGetState($CHECKBOX1) = 80 Then $INIT = TimerInit()
HotKeySet($SHOSTKEY, "_Stop")
Else
$INIT = 0
GUICtrlSetState($INPUT1, $GUI_ENABLE)
GUICtrlSetState($CHECKBOX3, $GUI_ENABLE)
GUICtrlSetState($CHECKBOX4, $GUI_ENABLE)
GUICtrlSetState($HIPXADD, $GUI_ENABLE)
If $MACENABLE = "是" And GUICtrlRead($CHECKBOX4) = 4 Then ControlClick($HGUI, "", $CHECKBOX4)
ControlClick($HGUI, "", $INPUT1)
Switch GUICtrlRead($BUTTON1)
Case 1
_GUICtrlStatusBar_SetText($HSTATUSBAR, "根据输入的计算机编号+偏移值自动计算出 IP 地址!")
GUICtrlSetData($BUTTON1, "根据偏移值计算 IP 地址(&Q)")
GUICtrlSetState($COMBO2, $GUI_ENABLE)
GUICtrlSetStyle($HIPXADD, $ES_CENTER + $ES_READONLY)
If GUICtrlRead($CHECKBOX3) = 4 Then GUICtrlSetState($HIPXADD, $GUI_DISABLE)
$PCNAME = GUICtrlRead($INPUT1)
$NUM = _GETFIRSTNUMFROMTEXT($PCNAME, $NUMLEN)
GUICtrlSetData($HIPXADD, StringFormat("%08d", $NUM))
If Not Number($IOFFSET) Then
Local $AIP = _GUICtrlIpAddress_GetArray($HIPADD1)
$IOFFSET = Number($AIP[2] * 254 + $AIP[3] - $NUM)
GUICtrlSetData($COMBO2, $IOFFSET)
EndIf
$MOVELEN = StringInStr($PCNAME, $IPOSTFIX)
If $MOVELEN Then
_GUICtrlEdit_SetSel($INPUT1, StringLen($IPREFIX), $MOVELEN - 1)
Else
_GUICtrlEdit_SetSel($INPUT1, StringLen($IPREFIX), StringLen($PCNAME))
EndIf
Case 4
_GUICtrlStatusBar_SetText($HSTATUSBAR, "手动输入计算机名和 IP 地址!")
GUICtrlSetData($BUTTON1, "使用手动输入的 IP 地址(&Q)")
GUICtrlSetState($COMBO2, $GUI_DISABLE)
If GUICtrlRead($CHECKBOX3) = 4 Then
GUICtrlSetStyle($HIPXADD, $ES_CENTER + $ES_READONLY)
Else
GUICtrlSetStyle($HIPXADD, $ES_CENTER + $ES_NUMBER)
EndIf
_GUICtrlEdit_SetSel($INPUT1, 0, StringLen(GUICtrlRead($INPUT1)))
_SETIPEDITSTATE()
EndSwitch
EndIf
EndIf
EndFunc ;==>_HGUIUPDATE
Func _VERGETARRAY($AVARRAY, $AVSTRING)
Local $I, $II
If IsArray($AVARRAY) Then
For $I = 0 To UBound($AVARRAY) - 1
For $II = 0 To UBound($AVARRAY, 2) - 1
If Not $AVARRAY[$I][$II] Then ContinueLoop
If StringLower($AVARRAY[$I][$II]) = StringLower($AVSTRING) Then Return $I
Next
Next
EndIf
SetError(1)
Return 0
EndFunc ;==>_VERGETARRAY
Func _GETFIRSTLETTERFROMTEXT($STEXT, $IOPT = 1)
Local $ALETTER
If $IOPT = -1 Then
$ALETTER = StringRegExp($STEXT, "\D+\d+(\w*)$", 3)
Else
$ALETTER = StringRegExp($STEXT, "\D+", 3)
EndIf
If Not IsArray($ALETTER) Then Return ""
Return $ALETTER[0]
EndFunc ;==>_GETFIRSTLETTERFROMTEXT
Func _GETFIRSTNUMFROMTEXT($STEXT, $ILEN)
Local $ANUM
$ANUM = StringRegExp($STEXT, "\d+", 2)
If Not IsArray($ANUM) Then Return StringFormat("%0" & $ILEN & "d", 0)
For $I = 0 To UBound($ANUM) - 1
If StringIsDigit($ANUM[$I]) Then Return StringFormat("%0" & $ILEN & "d", $ANUM[$I])
Next
EndFunc ;==>_GETFIRSTNUMFROMTEXT
Func _SETIPEDITSTATE($ISTATE = 1)
If Number($ISTATE) And Not ControlCommand($HGUI, "", $HIPADD1, "IsEnabled") Then
ControlEnable($HGUI, "", $HIPADD1)
ControlEnable($HGUI, "", $HIPADD2)
ControlEnable($HGUI, "", $HIPADD3)
ControlEnable($HGUI, "", $HIPADD4)
ControlEnable($HGUI, "", $HIPADD5)
ElseIf ControlCommand($HGUI, "", $HIPADD1, "IsEnabled") Then
ControlDisable($HGUI, "", $HIPADD1)
ControlDisable($HGUI, "", $HIPADD2)
ControlDisable($HGUI, "", $HIPADD3)
ControlDisable($HGUI, "", $HIPADD4)
ControlDisable($HGUI, "", $HIPADD5)
EndIf
EndFunc ;==>_SETIPEDITSTATE
Func _GETADDFORMNUMPREFIXOFFSET($DNUM, $SPREFIX = "", $DOFFSET = 0)
Local $SRETURN, $TMPVER, $FIX
If Not StringIsInt($DNUM) Then $DNUM = 1
If Not StringRegExp($SPREFIX, "((2[0-4]\d|25[0-5]|[01]?\d\d?)\.)(2[0-4]\d|25[0-5]|[01]?\d\d?)") Then
$FIX = StringSplit(@IPAddress1, ".")
$SPREFIX = $FIX[1] & "." & $FIX[2]
EndIf
If Not StringIsDigit($DOFFSET) Then $DOFFSET = 0
$DNUM = Abs($DNUM + $DOFFSET)
If $DNUM > 64770 Then $DNUM = 64770
If StringIsInt($DNUM / 254) = 1 Then
$SRETURN = $SPREFIX & "." & Int($DNUM / 255) & "." & $DNUM - Int($DNUM / 255) * 254
Else
$SRETURN = $SPREFIX & "." & Int($DNUM / 254) & "." & $DNUM - Int($DNUM / 254) * 254
EndIf
Return $SRETURN
EndFunc ;==>_GETADDFORMNUMPREFIXOFFSET
Func _FIXSTRING($STR, $IPRE = 1)
Local $SREGEXP = "[ `~!@#$^&*()=+\[\]{}\\|;:" & Chr(Asc("'")) & Chr(Asc(""" ) ) & ", <> /?] "
Local $RREGEXP = $SREGEXP & "\d*|^\d+"
If $IPRE = -1 Then
If Not StringRegExp($STR, $SREGEXP) Then Return $STR
Return StringRegExpReplace($STR, $SREGEXP, "")
Else
If Not StringRegExp($STR, $RREGEXP) Then Return $STR
Return StringRegExpReplace($STR, $RREGEXP, "")
EndIf
EndFunc ;==>_FIXSTRING
Func _STOP()
$INIT = -1
HotKeySet($SHOSTKEY)
_HGUIUPDATE()
EndFunc ;==>_STOP
Func _GETNETWORKNETINFO(ByRef $ANET)
Local $COLITEMS, $OBJWMISERVICE, $OBJITEM, $SDEVICEINFO
Local $SENUMKEY = "HKLM\SYSTEM\CurrentControlSet\Enum"
Local $SNWLNKIPX = "HKLM\SYSTEM\CurrentControlSet\Services\NwlnkIpx\Parameters"
Dim $ANET[1][10], $I = 1
$OBJWMISERVICE = ObjGet("winmgmts:\" & $CI_COMPNAME & "\root\CIMV2")
$COLITEMS = $OBJWMISERVICE.ExecQuery("SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionStatus >0", "WQL", $WBEMFLAGRETURNIMMEDIATELY + $WBEMFLAGFORWARDONLY)
If IsObj($COLITEMS) Then
For $OBJITEM In $COLITEMS
If $OBJITEM.MACAddress = "00:00:00:00:00:00" Then ContinueLoop
ReDim $ANET[UBound($ANET) + 1][10]
$ANET[$I][0] = $I
$ANET[$I][1] = $OBJITEM.NetConnectionID
$ANET[$I][2] = $OBJITEM.MACAddress
$ANET[$I][3] = _GETDEVICEDESC($OBJITEM.PNPDeviceID)
$SDEVICEINFO = StringFormat("%04d", $OBJITEM.DeviceID)
$SDEVICEINFO = _GETDEVICEINFO($SDEVICEINFO)
$ANET[$I][4] = $SDEVICEINFO[0]
$ANET[$I][5] = $SDEVICEINFO[1]
$ANET[$I][6] = $SDEVICEINFO[2]
$ANET[$I][7] = $SDEVICEINFO[3]
$ANET[$I][8] = $SDEVICEINFO[4]
$ANET[$I][9] = RegRead($SNWLNKIPX, "VirtualNetworkNumber")
$ANET[$I][9] = StringFormat("%08d", $ANET[$I][9])
$I += 1
Next
$ANET[0][0] = UBound($ANET) - 1
If $ANET[0][0] < 1 Then
SetError(1, 1, 0)
EndIf
Else
SetError(1, 2, 0)
EndIf
EndFunc ;==>_GETNETWORKNETINFO
Func _GETDEVICEINFO($SDEVICEID)
Local $ARRAYIP[5]
Local $SNETCFGINSTANCEID, $SNETSRVKEY
Local $SENUMKEY = _REGGETENUMKEY("HKLM\SYSTEM\CurrentControlSet\Control\Class", "Class", "Net")
$SENUMKEY = "HKLM\SYSTEM\CurrentControlSet\Control\Class" & $SENUMKEY & ""
$SNETCFGINSTANCEID = RegRead($SENUMKEY & $SDEVICEID, "NetCfgInstanceId")
$SNETSRVKEY = "HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interfaces" & $SNETCFGINSTANCEID
$ARRAYIP[0] = RegRead($SNETSRVKEY, "IPAddress")
If StringInStr($ARRAYIP[0], Chr(10)) Then $ARRAYIP[0] = StringMid($ARRAYIP[0], 1, StringInStr($ARRAYIP[0], Chr(10)) - 1)
$ARRAYIP[1] = RegRead($SNETSRVKEY, "SubnetMask")
If StringInStr($ARRAYIP[1], Chr(10)) Then $ARRAYIP[1] = StringMid($ARRAYIP[1], 1, StringInStr($ARRAYIP[1], Chr(10)) - 1)
$ARRAYIP[2] = RegRead($SNETSRVKEY, "DefaultGateway")
If StringInStr($ARRAYIP[2], Chr(10)) Then $ARRAYIP[2] = StringMid($ARRAYIP[2], 1, StringInStr($ARRAYIP[2], Chr(10)) - 1)
$ARRAYIP[3] = RegRead($SNETSRVKEY, "NameServer")
If StringInStr($ARRAYIP[3], Chr(44)) Then
$ARRAYIP[4] = StringMid($ARRAYIP[3], StringInStr($ARRAYIP[3], Chr(44)) + 1, StringInStr($ARRAYIP[3], Chr(44), 0, 2) - StringInStr($ARRAYIP[3], Chr(44)) - 1)
$ARRAYIP[3] = StringMid($ARRAYIP[3], 1, StringInStr($ARRAYIP[3], Chr(44)) - 1)
EndIf
Return $ARRAYIP
EndFunc ;==>_GETDEVICEINFO
Func _REGGETENUMKEY($K_NAME, $V_NAME, $S_VALUE)
Local $I, $SRETURN
$I = 0
While 1
$I += 1
$SRETURN = RegEnumKey($K_NAME, $I)
If @error <> 0 Then ExitLoop
If StringLower(RegRead($K_NAME & "" & $SRETURN, $V_NAME)) = StringLower($S_VALUE) Then Return $SRETURN
WEnd
EndFunc ;==>_REGGETENUMKEY
Func _GETDEVICEDESC($SPNPDEVICEID)
Local $SRETURN
Local $SENUMKEY = "HKLM\SYSTEM\CurrentControlSet\Enum"
$SRETURN = RegRead($SENUMKEY & $SPNPDEVICEID, "FriendlyName")
If Not $SRETURN Then Return RegRead($SENUMKEY & $SPNPDEVICEID, "DeviceDesc")
Return $SRETURN
EndFunc ;==>_GETDEVICEDESC
Func _TCPIpToName($SIP, $IOPTION = Default, $HDLL_WS2_32 = Default)
Local $VBINIP, $VADLLCALL, $VPTRHOSTENT, $VHOSTENT, $SHOSTNAMES, $VH_ALIASES, $I
Local $INADDR_NONE = -1, $AF_INET = 2, $SSEPERATOR = @CR
If $IOPTION = Default Then $IOPTION = 0
If $HDLL_WS2_32 = Default Then $HDLL_WS2_32 = "Ws2_32.dll"
$VADLLCALL = DllCall($HDLL_WS2_32, "long", "inet_addr", "str", $SIP)
If @error Then Return SetError(1, 0, "")
$VBINIP = $VADLLCALL[0]
If $VBINIP = $INADDR_NONE Then Return SetError(2, 0, "")
$VADLLCALL = DllCall($HDLL_WS2_32, "ptr", "gethostbyaddr", "long*", $VBINIP, "int", 4, "int", $AF_INET)
If @error Then Return SetError(3, 0, "")
$VPTRHOSTENT = $VADLLCALL[0]
If $VPTRHOSTENT = 0 Then
$VADLLCALL = DllCall($HDLL_WS2_32, "int", "WSAGetLastError")
If @error Then Return SetError(5, 0, "")
Return SetError(4, $VADLLCALL[0], "")
EndIf
$VHOSTENT = DllStructCreate("ptr;ptr;short;short;ptr", $VPTRHOSTENT)
$SHOSTNAMES = __TCPIPTONAME_SZSTRINGREAD(DllStructGetData($VHOSTENT, 1))
If @error Then Return SetError(6, 0, $SHOSTNAMES)
If $IOPTION = 1 Then
$SHOSTNAMES &= $SSEPERATOR
For $I = 0 To 63
$VH_ALIASES = DllStructCreate("ptr", DllStructGetData($VHOSTENT, 2) + ($I * 4))
If DllStructGetData($VH_ALIASES, 1) = 0 Then ExitLoop
$SHOSTNAMES &= __TCPIPTONAME_SZSTRINGREAD(DllStructGetData($VH_ALIASES, 1))
If @error Then
SetError(7)
ExitLoop
EndIf
Next
Return StringSplit(StringStripWS($SHOSTNAMES, 2), @CR)
Else
Return $SHOSTNAMES
EndIf
EndFunc ;==>_TCPIPTONAME
Func __TCPIPTONAME_SZSTRINGREAD($ISZPTR, $ILEN = -1, $HDLL_MSVCRT = "msvcrt.dll")
Local $ASTRLEN, $VSZSTRING
If $ISZPTR < 1 Then Return ""
If $ILEN < 0 Then
$ASTRLEN = DllCall($HDLL_MSVCRT, "int:cdecl", "strlen", "ptr", $ISZPTR)
If @error Then Return SetError(1, 0, "")
$ILEN = $ASTRLEN[0] + 1
EndIf
$VSZSTRING = DllStructCreate("char[" & $ILEN & "]", $ISZPTR)
If @error Then Return SetError(2, 0, "")
Return SetError(0, $ILEN, DllStructGetData($VSZSTRING, 1))
EndFunc ;==>__TCPIPTONAME_SZSTRINGREAD
Func _API_GET_NETWORKADAPTERMAC($SIP)
Local $MAC, $MACSIZE
Local $I, $S, $R, $IIP
$MAC = DllStructCreate("byte[6]")
$MACSIZE = DllStructCreate("int")
DllStructSetData($MACSIZE, 1, 6)
$R = DllCall("Ws2_32.dll", "int", "inet_addr", "str", $SIP)
$IIP = $R[0]
$R = DllCall("iphlpapi.dll", "int", "SendARP", "int", $IIP, "int", 0, "ptr", DllStructGetPtr($MAC), "ptr", DllStructGetPtr($MACSIZE))
$S = ""
For $I = 0 To 5
If $I Then $S = $S & ":"
$S = $S & Hex(DllStructGetData($MAC, 1, $I + 1), 2)
Next
If $S = "00:00:00:00:00:00" Then SetError(1)
Return $S
EndFunc ;==>_API_GET_NETWORKADAPTERMAC
Func _WMI_SETNETWORKADAPTERINFO($SDESCRIPTION, $SHOSTNAME, $IDHCP = 0, $SIPADD = "", $SSUBMASK = "", $SGATEWAY = "", $SDNS = "", $DIPX = "")
Local $OBJWMISERVICE, $COLITEMS, $OBJITEM, $I, $SRETURN = 0
If Not $SIPADD Then
$IDHCP = 1
ElseIf Not $IDHCP Then
$SIPADD = StringSplit($SIPADD, ",")
Local $AIPADDRESS[$SIPADD[0]]
For $I = 1 To $SIPADD[0]
$AIPADDRESS[$I - 1] = $SIPADD[$I]
Next
$SSUBMASK = StringSplit($SSUBMASK, ",")
Local $ASUBNETMASK[$SSUBMASK[0]]
For $I = 1 To $SSUBMASK[0]
$ASUBNETMASK[$I - 1] = $SSUBMASK[$I]
Next
$SGATEWAY = StringSplit($SGATEWAY, ",")
Local $AGATEWAY[$SGATEWAY[0]]
For $I = 1 To $SGATEWAY[0]
$AGATEWAY[$I - 1] = $SGATEWAY[$I]
Next
$SDNS = StringSplit($SDNS, ",")
Local $ADNS[$SDNS[0]]
For $I = 1 To $SDNS[0]
$ADNS[$I - 1] = $SDNS[$I]
Next
EndIf
$OBJWMISERVICE = ObjGet("winmgmts:\" & $CI_COMPNAME & "\root\CIMV2")
$COLITEMS = $OBJWMISERVICE.ExecQuery("Select * from Win32_ComputerSystem")
For $OBJITEM In $COLITEMS
$OBJITEM.Rename($SHOSTNAME)
Next
If $DIPX Then
$COLITEMS = $OBJWMISERVICE.Get("Win32_NetworkAdapterConfiguration")
$COLITEMS.SetIPXVirtualNetworkNumber(Hex($DIPX))
EndIf
If $SDESCRIPTION Then
$COLITEMS = $OBJWMISERVICE.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE Description = '" & $SDESCRIPTION & "'", "WQL", 16 + 32)
Else
$COLITEMS = $OBJWMISERVICE.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = TRUE", "WQL", 16 + 32)
EndIf
If IsObj($COLITEMS) Then
For $OBJITEM In $COLITEMS
If $IDHCP Then
If Not $OBJITEM.DHCPEnabled Then
$SRETURN += $OBJITEM.EnableDHCP
Else
$SRETURN = $OBJITEM.DHCPServer
EndIf
Else
$SRETURN += $OBJITEM.EnableStatic($AIPADDRESS, $ASUBNETMASK)
$SRETURN += $OBJITEM.SetGateways($AGATEWAY)
$SRETURN += $OBJITEM.SetDNSServerSearchOrder($ADNS)
EndIf
Next
EndIf
Return $SRETURN
EndFunc ;==>_WMI_SETNETWORKADAPTERINFO
Func _ADDRUNME($CLEANEVENT = 0)
Local $ICMD
$ICMD = " /autorun /listwait=" & _SETTIMEOUT()
If $CLEANEVENT Then $ICMD &= " /clean"
RegWrite("HKCU\Software\Microsoft\Windows\CurrentVersion\Runonce", "AutoAdds", "REG_SZ", @ScriptFullPath & $ICMD)
EndFunc ;==>_ADDRUNME
Func _REMOVEDEVICE()
Local $DEVCON
$DEVCON = _GETFILEFULLPATH("devcon.exe")
If Not FileExists($DEVCON) Then Return
RunWait($DEVCON & " remove = Monitor*", @SystemDir, @SW_HIDE)
RunWait($DEVCON & " remove =Volume&devcon remove =DiskDrive", @SystemDir, @SW_HIDE)
EndFunc ;==>_REMOVEDEVICE
Func _SETTIMEOUT($S = 33)
Local $STIMEOUT, $ARB
$STIMEOUT = IniRead(@HomeDrive & "\boot.ini", "boot loader", "timeout", "")
If $STIMEOUT Then
$ARB = FileGetAttrib(@HomeDrive & "\boot.ini")
If StringInStr($ARB, "R") Then FileSetAttrib(@HomeDrive & "\boot.ini", "-R")
If StringIsDigit($S) Then IniWrite(@HomeDrive & "\boot.ini", "boot loader", "timeout", $S)
FileSetAttrib(@HomeDrive & "\boot.ini", "+" & $ARB)
EndIf
Return $STIMEOUT
EndFunc ;==>_SETTIMEOUT
Func _CLEANEVENT($S = 0)
Local $OBJWMISERVICE, $COLITEMS, $OBJITEM, $ALOGS, $SLOG
$OBJWMISERVICE = ObjGet("winmgmts:" & "{impersonationLevel=impersonate,(Backup)}!\" & $CI_COMPNAME & "\root\cimv2")
Switch $S
Case 1
Local $ALOGS[1] = ["application"]
Case 2
Local $ALOGS[1] = ["security"]
Case 3
Local $ALOGS[2] = ["application", "security"]
Case 4
Local $ALOGS[1] = ["system"]
Case 5
Local $ALOGS[2] = ["application", "system"]
Case 6
Local $ALOGS[2] = ["security", "system"]
Case Else
Local $ALOGS[3] = ["application", "system", "security"]
EndSwitch
For $SLOG In $ALOGS
$COLITEMS = $OBJWMISERVICE.ExecQuery("Select * from Win32_NTEventLogFile where LogFileName="" & $SLOG & """)
For $OBJITEM In $COLITEMS
$OBJITEM.ClearEventLog()
Next
Next
EndFunc ;==>_CLEANEVENT
Func _KILLPOP()
If WinExists("系统设置改变", "") Then ControlClick("系统设置改变", "否", "Button2")
Local $I, $FW
$FW = StringSplit($SFUCK, "|")
For $I = 1 To $FW[0]
If Not $FW[$I] Or Not WinExists($FW[$I], "") Then ContinueLoop
WinClose($FW[$I])
Next
EndFunc ;==>_KILLPOP
不要顺手牵羊自己看看核心代码仅供参考