这种多网卡,是怎么实现的?如何在多网卡电脑中改IP&DNS?
http://www.autoitx.com/forum.php?mod=viewthread&tid=395&page=1&fromuid=7644076#pid2023 1 获取连接名称,然后通过netsh修改2 通过注册表修改 用NETSH....汗!!! 多谢分享了!!! 谢谢,学习了 Windows IP Configuration
Host Name . . . . . . . . . . . . : FQ-127
Primary Dns Suffix. . . . . . . :
Node Type . . . . . . . . . . . . : Unknown
IP Routing Enabled. . . . . . . . : No
WINS Proxy Enabled. . . . . . . . : No
Ethernet adapter 本地连接:
Connection-specific DNS Suffix. :
Description . . . . . . . . . . . : NVIDIA nForce Ne
Physical Address. . . . . . . . . : 00-1A-4D-95-BD-5
Dhcp Enabled. . . . . . . . . . . : No
IP Address. . . . . . . . . . . . : 192.168.0.127
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.0.1
DNS Servers . . . . . . . . . . . : 202.101.172.35
218.108.248.200
====================分割线===================
先调用dos命令ipconfig /all反回的数居(如上)里出现几次"Ethernet adapter"就说明有多少个网卡,它下面的"Description"项就是网卡型号~~改计算机名~~~ipx这些就是注册表的事情了,
改ip和dns用的是dos命令 把ipconfig /all反回的Ethernet adapter之后的"本地连接"存到变量里
然后用dos命令
netsh interface ip set address name="本地连接" source=static addr="要改的ip" mask=255.255.255.0 gateway=192.168.0.1 gwmetric=1 2个自定义函数,使用WMI。第1个获取网卡信息,第2个更改网卡IP设置。
多个网卡,只是索引不同。创建一个Combo控件,在下拉框列出所有网卡名称,根据用户选择得到对应网卡索引号。
下面代码第1段用于判断本机网卡数量,如果存在多个网卡则弹出窗口供选择。这是从我的某代码里复制的,没写头部定义,不能直接运行。
$aIfTable = _GetNetInfo()
If $aIfTable = 0 Then
MsgBox(0x10, "错误", "获取网络适配器设置失败,请检查网卡驱动。")
Exit 2
ElseIf $aIfTable = 1 Then
$NICIndex = $aIfTable
Else
; 创建“网卡选择”窗口
Local $hNICWnd, $hOKButton, $hIfTable
$hNICWnd = GUICreate($NBS_Name & " - 网卡选择", 284, 118)
GUICtrlCreateLabel("检测到本机安装有多个网络适配器,请选择用于更新的网卡。", 16, 16, 252, 24)
$hIfTable = GUICtrlCreateCombo("", 16, 48, 252, 12 * $aIfTable, BitOR($GUI_SS_DEFAULT_COMBO, $CBS_DROPDOWNLIST))
For $i = 1 To $aIfTable
GUICtrlSetData(-1, $aIfTable[$i] & ". " & $aIfTable[$i])
Next
GUICtrlSetData(-1, $aIfTable & ". " & $aIfTable)
$hOKButton = GUICtrlCreateButton("确定(&O)", 104, 80, 76, 22, $BS_DEFPUSHBUTTON)
; 窗口事件
GUISetState(@SW_SHOW)
While 1
Switch GUIGetMsg()
Case $hOKButton, $GUI_EVENT_CLOSE
$NICIndex = GUICtrlRead($hIfTable)
ExitLoop
EndSwitch
WEnd
GUIDelete($hNICWnd)
$NICIndex = StringLeft($NICIndex, StringInStr($NICIndex, ".") - 1)
EndIf
;===============================================================================
; 说明: 获取网络适配器信息
; 语法: _GetNetInfo([$strComputer = "localhost"])
; 参数: $strComputer - [可选] 计算机名称
; 需要: WMI 服务
; 返回: 成功 - 二维数组, 结构:
; $array - 网络适配器总数
; $array - 第一网络适配器索引
; $array - 第一网络适配器名称
; $array - 第一网络适配器连接名
; $array - 第一网络适配器连接状态
; $array - 第一网络适配器MAC地址
; $array - 第一网络适配器DHCP状态
; $array - 第一网络适配器IP地址
; $array - 第一网络适配器子网掩码
; $array - 第一网络适配器默认网关
; $array - 第一网络适配器首选 DNS
; $array - 第一网络适配器备用 DNS
; ...
; 至 - 第 n 网络适配器信息
; 失败 - 空列表数组 = 0, 并设置 @error 到
; 1 - 没有可用网络适配器
; 2 - 获取 COM 对象失败
; 备注: 无
;===============================================================================
Func _GetNetInfo($strComputer = "localhost")
Local $objWMIService, $colItems, $objItem, $iItem, $aNetInfo = []
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
If @error Then Return SetError(2, 0, $aNetInfo)
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True", "WQL", 0x10 + 0x20)
If IsObj($colItems) Then
For $objItem In $colItems
$aNetInfo += 1
$iItem = $aNetInfo
ReDim $aNetInfo[$iItem + 1]
$aNetInfo[$iItem] = $objItem.Index
$aNetInfo[$iItem] = $objItem.Description
$aNetInfo[$iItem] = $objItem.MACAddress
$aNetInfo[$iItem] = $objItem.DHCPEnabled
$aNetInfo[$iItem] = $objItem.IPAddress(0)
$aNetInfo[$iItem] = $objItem.IPSubnet(0)
$aNetInfo[$iItem] = $objItem.DefaultIPGateway(0)
$aNetInfo[$iItem] = $objItem.DNSServerSearchOrder(0)
$aNetInfo[$iItem] = $objItem.DNSServerSearchOrder(1)
If NOT StringRegExp($aNetInfo[$iItem], "^({2}:){5}{2}$") _
Then $aNetInfo[$iItem] = ""
If $aNetInfo[$iItem] Then $aNetInfo[$iItem] = 1
If NOT StringRegExp($aNetInfo[$iItem], "^((25|2\d|?\d?\d)\.){3}(25|2\d|?\d?\d)$") _
Then $aNetInfo[$iItem] = ""
If NOT StringRegExp($aNetInfo[$iItem], "^((25|2\d|?\d?\d)\.){3}(25|2\d|?\d?\d)$") _
Then $aNetInfo[$iItem] = ""
If NOT StringRegExp($aNetInfo[$iItem], "^((25|2\d|?\d?\d)\.){3}(25|2\d|?\d?\d)$") _
Then $aNetInfo[$iItem] = ""
If NOT StringRegExp($aNetInfo[$iItem], "^((25|2\d|?\d?\d)\.){3}(25|2\d|?\d?\d)$") _
Then $aNetInfo[$iItem] = ""
If NOT StringRegExp($aNetInfo[$iItem], "^((25|2\d|?\d?\d)\.){3}(25|2\d|?\d?\d)$") _
Then $aNetInfo[$iItem] = ""
Next
EndIf
If $aNetInfo = 0 Then Return SetError(1, 0, $aNetInfo)
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter WHERE AdapterType = 'Ethernet 802.3'", "WQL", 0x10 + 0x20)
If IsObj($colItems) Then
For $objItem In $colItems
For $i = 1 To $aNetInfo
If $aNetInfo[$i] = $objItem.Index Then
$aNetInfo[$i] = $objItem.Description
$aNetInfo[$i] = $objItem.NetConnectionID
$aNetInfo[$i] = $objItem.NetConnectionStatus
ExitLoop
EndIf
Next
Next
EndIf
Return $aNetInfo
EndFunc ;==>_GetNetInfo
;===============================================================================
; 说明: 更改网络适配器IP设置
; 语法: _ChangeNetCfg($iIndex, $sIPAddr[, $sSubnet = "255.255.255.0"[, $sGateway = ""[, $sDNS1 = ""[, $sDNS2 = ""[, $strComputer = "localhost"]]]]])
; 参数: $iIndex - 网络适配器索引
; $sIPAddr - IP地址
; $sSubnet - [可选] 子网掩码
; $sGateway - [可选] 默认网关
; $sDNS1 - [可选] 首选 DNS
; $sDNS2 - [可选] 备用 DNS
; $strComputer - [可选] 计算机名称
; 需要: WMI 服务
; 返回: 成功 - 1
; 失败 - 0, 并设置 @error 到
; 1 - 网络设置更改失败
; 2 - 没有可用网络适配器
; 3 - 地址格式错误
; 4 - 获取 COM 对象失败
; 备注: 无
;===============================================================================
Func _ChangeNetCfg($iIndex, $sIPAddr, $sSubnet = "255.255.255.0", $sGateway = "", $sDNS1 = "", $sDNS2 = "", $strComputer = "localhost")
Local $asIPAddr, $asSubnet, $asGateway, $asDNS
Local $objWMIService, $colItems, $objItem
If NOT StringRegExp($sIPAddr, "^((25|2\d|?\d?\d)\.){3}(25|2\d|?\d?\d)$") Then Return SetError(3, 0, 0)
If NOT StringRegExp($sSubnet, "^((25|2\d|?\d?\d)\.){3}(25|2\d|?\d?\d)$") Then Return SetError(3, 0, 0)
If $sGateway AND NOT StringRegExp($sGateway, "^((25|2\d|?\d?\d)\.){3}(25|2\d|?\d?\d)$") Then Return SetError(3, 0, 0)
If $sDNS1 AND NOT StringRegExp($sDNS1, "^((25|2\d|?\d?\d)\.){3}(25|2\d|?\d?\d)$") Then Return SetError(3, 0, 0)
If $sDNS2 AND NOT StringRegExp($sDNS2, "^((25|2\d|?\d?\d)\.){3}(25|2\d|?\d?\d)$") Then Return SetError(3, 0, 0)
$asIPAddr = $sIPAddr
$asSubnet = $sSubnet
$asGateway = $sGateway
$asDNS = $sDNS1
$asDNS = $sDNS2
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
If @error Then Return SetError(4, 0, 0)
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE Index = " & $iIndex, "WQL", 0x10 + 0x20)
For $objItem In $colItems
If $objItem.EnableStatic($asIPAddr, $asSubnet) > 1 Then Return SetError(1, 0, 0)
If $asGateway AND $objItem.SetGateways($asGateway) > 1 Then Return SetError(1, 0, 0)
If $asDNS Then $objItem.SetDNSServerSearchOrder($asDNS)
Return 1
Next
Return SetError(2, 0, 0)
EndFunc ;==>_ChangeNetCfg 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 Then
For $I = 1 To $CMDLINE
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 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, 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 = [@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, $H_POS, $H_POS, $H_POS, BitOR($WS_CAPTION, $WS_SYSMENU))
GUISetIcon("shell32.dll", 268)
$HSTATUSBAR = _GUICtrlStatusBar_Create($HGUI, -1, "")
Local $HICONS
Local $APARTS = [$H_POS - 93, -1]
_GUICtrlStatusBar_SetParts($HSTATUSBAR, $APARTS)
_GUICtrlStatusBar_SetText($HSTATUSBAR, $G_SZVERSION)
_GUICtrlStatusBar_SetText($HSTATUSBAR, "Make By Amu", 1)
$HICONS = _WinAPI_LoadShell32Icon(221)
$HICONS = _WinAPI_LoadShell32Icon(160)
_GUICtrlStatusBar_SetIcon($HSTATUSBAR, 0, $HICONS)
_GUICtrlStatusBar_SetIcon($HSTATUSBAR, 1, $HICONS)
Local $XY =
$GROUP1 = GUICtrlCreateGroup("基本信息", $XY - 15, $XY - 20, $H_POS - 14, 132)
GUICtrlCreateLabel("网络适配器(&S):", $XY, $XY, 81, 18, $SS_LEFT + $SS_CENTERIMAGE)
$COMBO1 = GUICtrlCreateCombo($NETINFO[$NETINFO], $XY + 81 + 5, $XY, 320, 18, BitOR($CBS_DROPDOWNLIST, $CBS_AUTOHSCROLL))
For $I = 1 To $NETINFO
GUICtrlSetData($COMBO1, $NETINFO[$I])
Next
GUICtrlCreateLabel("计算机名(&N):", $XY, $XY + 28, 70, 18, $SS_LEFT + $SS_CENTERIMAGE)
$INPUT1 = GUICtrlCreateInput(@ComputerName, $XY + 80 + 5, $XY + 28, 178, 18, $SS_CENTER)
GUICtrlSetTip(-1, "请输入纯数字")
$HCS15CDK = GUICtrlCreateLabel("偏移值(&F):", $XY + 80 + 5 + 80 + 120, $XY + 28, 61, 18, $SS_CENTERIMAGE)
$COMBO2 = GUICtrlCreateInput("0", $XY + 80 + 5 + 80 + 120 + 61 + 5, $XY + 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 + 5, $XY + 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 + 250, $XY + 28 * 2, 160, 18)
$CHECKBOX3 = GUICtrlCreateCheckbox("修改 IPX 内部网络号(&T):", $XY + 5, $XY + 28 * 3, 160, 18)
$HIPXADD = GUICtrlCreateInput($NETINFO[$NETINFO], $XY + 165, $XY + 28 * 3, 60, 18, $ES_NUMBER + $SS_CENTER)
GUICtrlSetLimit(-1, 8)
GUICtrlSetTip(-1, "请输入十进制数字")
$CHECKBOX4 = GUICtrlCreateCheckbox("修改 MAC 地址(&W)", $XY + 250, $XY + 28 * 3, 120, 18)
GUICtrlSetTip(-1, "暂时不支持修改 MAC 地址")
If $DHCPENABLE = "是" Then GUICtrlSetState($CHECKBOX2, 1)
$BUTTON1 = GUICtrlCreateCheckbox("使用手动输入的 IP 地址(&Q)", $XY - 14, $XY + 28 * 3 + 10 + 140, 160, 20, $BS_PUSHLIKE)
$BUTTON2 = GUICtrlCreateButton("配置(&O)", $XY - 14 + 180 + 5, $XY + 28 * 3 + 10 + 140, 60, 20)
$BUTTON3 = GUICtrlCreateButton("修改(&Z)", $XY - 14 + 180 + 25 + 60 + 25, $XY + 28 * 3 + 10 + 140, 60, 20)
$BUTTON4 = GUICtrlCreateButton("取消(&C)", 381, $XY + 28 * 3 + 10 + 140, 60, 20)
Local $BS = [$XY, $XY + 28 * 5]
$GROUP2 = GUICtrlCreateGroup("", $BS - 15, $BS - 24, $H_POS - 14, 110)
$LABEL1 = GUICtrlCreateLabel("MAC 地址(&M):", $BS + 200 + 10, $BS, 70, 18, $SS_LEFT + $SS_CENTERIMAGE)
$HMACADD = GUICtrlCreateInput("", $BS + 280 + 5, $BS, 120, 18)
GUICtrlSetStyle(-1, $SS_CENTER + $ES_READONLY)
GUICtrlSetData($HMACADD, $NETINFO[$NETINFO])
If GUICtrlRead($CHECKBOX4) = 4 Then GUICtrlSetState($HMACADD, $GUI_DISABLE)
$LABEL2 = GUICtrlCreateLabel("IP 地址(&I):", $BS, $BS, 72, 18, $SS_RIGHT + $SS_CENTERIMAGE)
$HIPADD1 = _GUICtrlIpAddress_Create($HGUI, $BS + 70 + 5, $BS, 120, 18)
_GUICtrlIpAddress_Set($HIPADD1, @IPAddress1)
GUICtrlCreateLabel("子网掩码(&U):", $BS, $BS + 26, 70, 18, $SS_LEFT + $SS_CENTERIMAGE)
$HIPADD2 = _GUICtrlIpAddress_Create($HGUI, $BS + 70 + 5, $BS + 26, 120, 18)
_GUICtrlIpAddress_Set($HIPADD2, $ISUBNET)
$LABEL3 = GUICtrlCreateLabel("默认网关(&D):", $BS + 200 + 10, $BS + 26, 70, 18, $SS_LEFT + $SS_CENTERIMAGE)
$HIPADD3 = _GUICtrlIpAddress_Create($HGUI, $BS + 280 + 5, $BS + 26, 120, 18)
_GUICtrlIpAddress_Set($HIPADD3, $IGATEWAY)
$LABEL4 = GUICtrlCreateLabel("首选 DNS(&P):", $BS, $BS + 26 * 2, 70, 18, $SS_LEFT + $SS_CENTERIMAGE)
$HIPADD4 = _GUICtrlIpAddress_Create($HGUI, $BS + 70 + 5, $BS + 26 * 2, 120, 18)
_GUICtrlIpAddress_Set($HIPADD4, $IDNS1)
GUICtrlCreateLabel("备用 DNS(&A):", $BS + 200 + 10, $BS + 26 * 2, 70, 18, $SS_LEFT + $SS_CENTERIMAGE)
$HIPADD5 = _GUICtrlIpAddress_Create($HGUI, $BS + 280 + 5, $BS + 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, 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, $CHECKBOX, $IPADD, $BUTTON, $AIP0, $AIP1
Local $XY =
Local $N_POS = WinGetPos($HGUI)
$NGUI = GUICreate("配置", $N_POS - 25, $N_POS - 66, $N_POS + 22, $N_POS + 22, BitOR($WS_CAPTION, $WS_SYSMENU), $WS_EX_CONTEXTHELP, $HGUI)
GUICtrlCreateGroup("基本设置", $XY - 11, $XY - 20, 410, $XY + 28 * 4 + 8)
GUICtrlCreateLabel("机名前缀:", $XY, $XY, 55, 18, $SS_LEFT + $SS_CENTERIMAGE)
$INPUT = GUICtrlCreateInput($IPREFIX, $XY + 55 + 5, $XY, 80, 18, $SS_CENTER)
GUICtrlCreateLabel("机名后缀:", $XY + 55 + 5 + 80 + 10, $XY, 55, 18, $SS_LEFT + $SS_CENTERIMAGE)
$INPUT = GUICtrlCreateInput($IPOSTFIX, $XY + 55 * 2 + 5 * 2 + 80 + 10, $XY, 60, 18, $SS_CENTER)
GUICtrlCreateLabel("偏移值:", $XY + 55 * 2 + 5 * 2 + 80 + 10 + 70, $XY, 41, 18, $SS_LEFT + $SS_CENTERIMAGE)
$INPUT = GUICtrlCreateInput($IOFFSET, $XY + 55 * 2 + 5 * 2 + 80 + 10 + 70 + 41 + 5, $XY, 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, $XY + 28, 55, 18, $SS_LEFT + $SS_CENTERIMAGE)
$INPUT = GUICtrlCreateInput($IPFIX, $XY + 55 + 5, $XY + 28, 55, 18, $SS_CENTER)
GUICtrlCreateGroup("", 142, $XY + 20, 257, 28)
$CHECKBOX = GUICtrlCreateCheckbox("改IPX编号", 150, $XY + 29, 70, 17, $BS_RIGHTBUTTON)
GUICtrlSetState(-1, 1)
$CHECKBOX = GUICtrlCreateCheckbox("改MAC地址", 230, $XY + 29, 70, 17, $BS_RIGHTBUTTON)
$CHECKBOX = GUICtrlCreateCheckbox("使用DHCP", 323, $XY + 29, 65, 17, $BS_RIGHTBUTTON)
GUICtrlCreateLabel("子网掩码:", $XY, $XY + 28 * 2 + 8, 55, 18, $SS_LEFT + $SS_CENTERIMAGE)
$IPADD = _GUICtrlIpAddress_Create($NGUI, $XY + 55 + 5, $XY + 28 * 2 + 8, 120, 18)
_GUICtrlIpAddress_Set($IPADD, $ISUBNET)
GUICtrlCreateLabel("默认网关:", $XY + 55 + 5 + 140, $XY + 28 * 2 + 8, 55, 18, $SS_LEFT + $SS_CENTERIMAGE)
$IPADD = _GUICtrlIpAddress_Create($NGUI, $XY + 55 * 2 + 5 * 2 + 140, $XY + 28 * 2 + 8, 120, 18)
_GUICtrlIpAddress_Set($IPADD, $IGATEWAY)
GUICtrlCreateLabel("首选 DNS:", $XY, $XY + 28 * 3 + 8, 55, 18, $SS_LEFT + $SS_CENTERIMAGE)
$IPADD = _GUICtrlIpAddress_Create($NGUI, $XY + 55 + 5, $XY + 28 * 3 + 8, 120, 18)
_GUICtrlIpAddress_Set($IPADD, $IDNS1)
GUICtrlCreateLabel("备用 DNS:", $XY + 55 + 5 + 140, $XY + 28 * 3 + 8, 55, 18, $SS_LEFT + $SS_CENTERIMAGE)
$IPADD = _GUICtrlIpAddress_Create($NGUI, $XY + 55 * 2 + 5 * 2 + 140, $XY + 28 * 3 + 8, 120, 18)
_GUICtrlIpAddress_Set($IPADD, $IDNS2)
$XY = 174
GUICtrlCreateGroup("", $XY - 11, $XY - 20, 410, 82)
GUICtrlCreateLabel("调用程序:", $XY, $XY, 55, 18, $SS_LEFT + $SS_CENTERIMAGE)
$INPUT = GUICtrlCreateInput($IDFPATH, $XY + 55 + 5, $XY, 240, 18)
$BUTTON = GUICtrlCreateButton("浏览(&B)...", 330, $XY - 1, 70, 20)
GUICtrlCreateLabel("程序参数:", $XY, $XY + 28, 55, 18, $SS_LEFT + $SS_CENTERIMAGE)
$INPUT = GUICtrlCreateInput($IDFCMD, $XY + 55 + 5, $XY + 28, 210, 18)
GUICtrlSetTip(-1, $IDFCMD)
GUICtrlCreateLabel("倒计时:", 300, $XY + 28, 41, 18, $SS_LEFT + $SS_CENTERIMAGE)
GUICtrlCreateLabel("秒", 300 + 82 + 6, $XY + 28, 16, 18, $SS_LEFT + $SS_CENTERIMAGE)
$INPUT = GUICtrlCreateInput($ITIME, 300 + 41 + 3, $XY + 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 = 245
$BUTTON = GUICtrlCreateButton("取消(&C)", $XY + 20, $XY, 55, 20)
$BUTTON = GUICtrlCreateButton("保存(&Z)", $XY + 100, $XY, 55, 20)
$BUTTON = GUICtrlCreateButton("扫描 MAC 地址(&E)", $XY + 255, $XY, 110, 20, $BS_PUSHLIKE)
$XY = 300
GUIStartGroup()
GUICtrlCreateGroup("扫描 MAC 地址", $XY - 11, $XY - 20, 410, 190)
GUICtrlCreateLabel("从", $XY + 3, $XY, 16, 18, $SS_LEFT + $SS_CENTERIMAGE)
$IPADD = _GUICtrlIpAddress_Create($NGUI, $XY + 18, $XY, 120, 18)
GUICtrlCreateLabel("到", $XY + 141, $XY, 16, 18, $SS_LEFT + $SS_CENTERIMAGE)
$IPADD = _GUICtrlIpAddress_Create($NGUI, $XY + 156, $XY, 120, 18)
$BUTTON = GUICtrlCreateCheckbox("扫描(&S)", $XY + 310, $XY - 1, 55, 20, $BS_PUSHLIKE)
GUICtrlSetState(-1, $GUI_DISABLE)
$HLISTVIEW = GUICtrlCreateListView("MAC 地址|计算机名|IP地址", $XY + 3, $XY + 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)
$AIP1 = _GUICtrlIpAddress_GetArray($IPADD)
Select
Case $MMSG = $GUI_EVENT_CLOSE
Switch $MMSG
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 = $BUTTON
$IDFPATH = FileOpenDialog("请选择要调用的程序", "", "程序(*.exe;*.com)", 1, "DF6Wks.exe")
If Not @error Then GUICtrlSetData($INPUT, $IDFPATH)
Case $MMSG = $BUTTON
ExitLoop
Case $MMSG = $BUTTON
$IPREFIX = GUICtrlRead($INPUT)
$IPOSTFIX = GUICtrlRead($INPUT)
$IOFFSET = GUICtrlRead($INPUT)
$IPFIX = GUICtrlRead($INPUT)
$ISUBNET = _GUICtrlIpAddress_Get($IPADD)
$IGATEWAY = _GUICtrlIpAddress_Get($IPADD)
$IDNS1 = _GUICtrlIpAddress_Get($IPADD)
$IDNS2 = _GUICtrlIpAddress_Get($IPADD)
$IPXENABLE = GUICtrlRead($CHECKBOX)
$MACENABLE = GUICtrlRead($CHECKBOX)
$DHCPENABLE = GUICtrlRead($CHECKBOX)
$IDFPATH = GUICtrlRead($INPUT)
$IDFCMD = GUICtrlRead($INPUT)
$ITIME = GUICtrlRead($INPUT)
$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 = $BUTTON
Local $N_POS = WinGetPos($NGUI)
Local $D_POS = ControlGetPos("Program Manager", "FolderView", "SysListView321")
Switch $SCANMACSHOW
Case 1
WinMove($NGUI, "", $N_POS, $N_POS, $N_POS, $N_POS - 205)
GUICtrlSetState($BUTTON, $GUI_DISABLE)
$SCANMACSHOW = 0
Case Else
GUICtrlSetState($BUTTON, $GUI_ENABLE)
If $N_POS > $D_POS - $N_POS - 205 Then $N_POS = $D_POS - $N_POS - 205
WinMove($NGUI, "", $N_POS, $N_POS, $N_POS, $N_POS + 205)
$SCANMACSHOW = 1
EndSwitch
Case $MMSG = $BUTTON
Switch GUICtrlRead($BUTTON)
Case 1
TCPStartup()
Local $ISTEP = 1
If $AIP0 > $AIP1 Then $ISTEP = -1
For $I = $AIP0 To $AIP1 Step $ISTEP
$NIP = $AIP0 & "." & $AIP0 & "." & $AIP0 & "." & $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)
Case Else
EndSwitch
Case Else
For $I = 0 To 2
If $AIP1[$I] >= $AIP0[$I] Then ContinueLoop
$AIP1[$I] = $AIP0[$I]
_GUICtrlIpAddress_SetArray($IPADD, $AIP1)
Next
EndSelect
WEnd
$N_POS = WinGetPos($NGUI)
WinMove($HGUI, "", $N_POS - 22, $N_POS - 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]
Local $LMACADD = $NETINFO[$L]
Local $LIPXADD = $NETINFO[$L]
Local $LIPADD = $NETINFO[$L]
Local $LSUBNET = $NETINFO[$L]
Local $LGATEWAY = $NETINFO[$L]
Local $LDNS1 = $NETINFO[$L]
Local $LDNS2 = $NETINFO[$L]
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 <> 2 Then
$PCNAME = GUICtrlRead($INPUT1)
$IIPADD = _GUICtrlIpAddress_Get($HIPADD1)
Else
$PCNAME = $NAMEANDIP
$IIPADD = $NAMEANDIP
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\d|25|?\d\d?)\.){3}(2\d|25|?\d\d?)") Then
_GUICtrlIpAddress_Set($HIPADD1, $IIPADD)
$INIT = -1
EndIf
If $ISUBNET <> $LSUBNET And StringRegExp($ISUBNET, "((2\d|25|?\d\d?)\.){3}(2\d|25|?\d\d?)") Then
_GUICtrlIpAddress_Set($HIPADD2, $ISUBNET)
$INIT = -1
EndIf
If $IGATEWAY <> $LGATEWAY And StringRegExp($IGATEWAY, "((2\d|25|?\d\d?)\.){3}(2\d|25|?\d\d?)") Then
_GUICtrlIpAddress_Set($HIPADD3, $IGATEWAY)
$INIT = -1
EndIf
If $IDNS1 <> $LDNS1 And StringRegExp($IDNS1, "((2\d|25|?\d\d?)\.){3}(2\d|25|?\d\d?)") Then
_GUICtrlIpAddress_Set($HIPADD4, $IDNS1)
$INIT = -1
EndIf
If $IDNS1 <> $LDNS1 And StringRegExp($IDNS1, "((2\d|25|?\d\d?)\.){3}(2\d|25|?\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 * 254 + $AIP - $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
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\d|25|?\d\d?)\.)(2\d|25|?\d\d?)") Then
$FIX = StringSplit(@IPAddress1, ".")
$SPREFIX = $FIX & "." & $FIX
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, $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
$ANET[$I] = $I
$ANET[$I] = $OBJITEM.NetConnectionID
$ANET[$I] = $OBJITEM.MACAddress
$ANET[$I] = _GETDEVICEDESC($OBJITEM.PNPDeviceID)
$SDEVICEINFO = StringFormat("%04d", $OBJITEM.DeviceID)
$SDEVICEINFO = _GETDEVICEINFO($SDEVICEINFO)
$ANET[$I] = $SDEVICEINFO
$ANET[$I] = $SDEVICEINFO
$ANET[$I] = $SDEVICEINFO
$ANET[$I] = $SDEVICEINFO
$ANET[$I] = $SDEVICEINFO
$ANET[$I] = RegRead($SNWLNKIPX, "VirtualNetworkNumber")
$ANET[$I] = StringFormat("%08d", $ANET[$I])
$I += 1
Next
$ANET = UBound($ANET) - 1
If $ANET < 1 Then
SetError(1, 1, 0)
EndIf
Else
SetError(1, 2, 0)
EndIf
EndFunc ;==>_GETNETWORKNETINFO
Func _GETDEVICEINFO($SDEVICEID)
Local $ARRAYIP
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 = RegRead($SNETSRVKEY, "IPAddress")
If StringInStr($ARRAYIP, Chr(10)) Then $ARRAYIP = StringMid($ARRAYIP, 1, StringInStr($ARRAYIP, Chr(10)) - 1)
$ARRAYIP = RegRead($SNETSRVKEY, "SubnetMask")
If StringInStr($ARRAYIP, Chr(10)) Then $ARRAYIP = StringMid($ARRAYIP, 1, StringInStr($ARRAYIP, Chr(10)) - 1)
$ARRAYIP = RegRead($SNETSRVKEY, "DefaultGateway")
If StringInStr($ARRAYIP, Chr(10)) Then $ARRAYIP = StringMid($ARRAYIP, 1, StringInStr($ARRAYIP, Chr(10)) - 1)
$ARRAYIP = RegRead($SNETSRVKEY, "NameServer")
If StringInStr($ARRAYIP, Chr(44)) Then
$ARRAYIP = StringMid($ARRAYIP, StringInStr($ARRAYIP, Chr(44)) + 1, StringInStr($ARRAYIP, Chr(44), 0, 2) - StringInStr($ARRAYIP, Chr(44)) - 1)
$ARRAYIP = StringMid($ARRAYIP, 1, StringInStr($ARRAYIP, 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
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
If $VPTRHOSTENT = 0 Then
$VADLLCALL = DllCall($HDLL_WS2_32, "int", "WSAGetLastError")
If @error Then Return SetError(5, 0, "")
Return SetError(4, $VADLLCALL, "")
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 + 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")
$MACSIZE = DllStructCreate("int")
DllStructSetData($MACSIZE, 1, 6)
$R = DllCall("Ws2_32.dll", "int", "inet_addr", "str", $SIP)
$IIP = $R
$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]
For $I = 1 To $SIPADD
$AIPADDRESS[$I - 1] = $SIPADD[$I]
Next
$SSUBMASK = StringSplit($SSUBMASK, ",")
Local $ASUBNETMASK[$SSUBMASK]
For $I = 1 To $SSUBMASK
$ASUBNETMASK[$I - 1] = $SSUBMASK[$I]
Next
$SGATEWAY = StringSplit($SGATEWAY, ",")
Local $AGATEWAY[$SGATEWAY]
For $I = 1 To $SGATEWAY
$AGATEWAY[$I - 1] = $SGATEWAY[$I]
Next
$SDNS = StringSplit($SDNS, ",")
Local $ADNS[$SDNS]
For $I = 1 To $SDNS
$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 = ["application"]
Case 2
Local $ALOGS = ["security"]
Case 3
Local $ALOGS = ["application", "security"]
Case 4
Local $ALOGS = ["system"]
Case 5
Local $ALOGS = ["application", "system"]
Case 6
Local $ALOGS = ["security", "system"]
Case Else
Local $ALOGS = ["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
If Not $FW[$I] Or Not WinExists($FW[$I], "") Then ContinueLoop
WinClose($FW[$I])
Next
EndFunc ;==>_KILLPOP
不要顺手牵羊自己看看核心代码仅供参考 看的要费电时间咯 这个好牛逼,真是需要的
页:
[1]