迷失左岸 发表于 2010-2-6 17:39:14

IP地址随意换

本帖最后由 迷失左岸 于 2010-2-9 10:55 编辑

请大家帮忙看下这源码,出错,谢.这是在论坛看到的源码,好像有问题,请大家解决一下.

#NoTrayIcon
#Region ;**** 参数创建于 AutoIt3Wrapper_GUI ****
#AutoIt3Wrapper_icon=..\IP地址随意换源码.ico
#AutoIt3Wrapper_outfile=1.exe
#AutoIt3Wrapper_Compression=4
#AutoIt3Wrapper_Res_Comment=IP地址随意换 V1.2
#AutoIt3Wrapper_Res_Description=IP地址随意换 V1.2 ㊣版技术联合·综合群特别版 作者:Sunny
#AutoIt3Wrapper_Res_Fileversion=1.2.0.0
#AutoIt3Wrapper_Res_LegalCopyright=版权所有(C)2002-2008 ㊣版技术联合·综合群
#AutoIt3Wrapper_Res_Field=QQ/TM|18180559
#AutoIt3Wrapper_Res_Field=QQ群|18115990
#AutoIt3Wrapper_Res_Field=软件网站|http://www.Sunny.com
#AutoIt3Wrapper_Res_Field=作者:|Sunny
#AutoIt3Wrapper_Res_Field=产品版本|1.2.0.0
#AutoIt3Wrapper_Res_Field=产品名称|IP地址随意换 V1.2
#AutoIt3Wrapper_Res_Field=内部说明|IP地址随意换 V1.2 ㊣版技术联合·综合群特别版 作者:Sunny 不得用于任何商业目的!最终解释权在㊣版技术联合·综合群!
#AutoIt3Wrapper_Res_Field=公司|㊣版技术联合·综合群
#AutoIt3Wrapper_Res_Field=合法商标|㊣版技术联合·综合
#AutoIt3Wrapper_Res_Field=内部名称|IP地址随意换.exe
#AutoIt3Wrapper_Res_Field=源文件名|IP地址随意换
#EndRegion ;**** Directives created by AutoIt3Wrapper_GUI ****
#cs ----------------------------------------------------------------------------
      AutoIt 版本: 3.4.7.3第一版)
      脚本作者: Sunny
      Email: sunwei4616@139.com
      QQ/TM: 18180559
      BLOG :http://www.Sunny.com
      脚本名称:IP地址随意换
      脚本版本:1.2
      脚本功能:添加、保存TCP/IP配置方案,方便快速切换IP配置
         
#ce ----------------------------------------------------------------------------

; 脚本开始 - 在这后面添加您的代码.

#include <GUIConstants.au3>
#include <GuiIPAddress.au3>
AutoItSetOption("TrayAutoPause", 0)
TraySetClick(8)
Opt("traymenumode", 1)
TraySetToolTip("IP地址随意换 V1.2 作者:Sunny <HanDou>")

_CreatFile()
$g_szVersion = "IP地址随意换 V1.2 作者:Sunny <HanDou>"
If WinExists($g_szVersion,"IP配置列表") Then Exit
AutoItWinSetTitle($g_szVersion)

$wbemFlagReturnImmediately = 0x10
$wbemFlagForwardOnly = 0x20
$strComputer = "localhost"
$BS_FLAT=0x8000
$WS_CHILD=0x40000000
$mainwindow = GUICreate("IP地址随意换 V1.2 作者:Sunny ", 500, 370, @DesktopWidth / 2 - 500 / 2, @DesktopHeight / 2 - 370 / 2)
$group1 = GUICtrlCreateGroup("IP配置列表:", 10, 15, 255, 165)
$List1 = GUICtrlCreateList("", 92, 35, 161, 135)
$SectionNames = IniReadSectionNames(@ScriptDir & "\IP Configlist.ini")
If $SectionNames <> 1 Then
      For $i = 1 To $SectionNames
                GUICtrlSetData($List1, $SectionNames[$i], $SectionNames)
      Next
Else
      Dim $SectionNames
      $SectionNames = ""
EndIf
$setip = GUICtrlCreateButton("切换配置", 20, 35, 67, 30, $BS_FLAT)
$config = GUICtrlCreateButton("修改配置", 20, 68, 68, 30, $BS_FLAT)
$Add = GUICtrlCreateButton("添加配置", 20, 101, 68, 30, $BS_FLAT)
$Delete = GUICtrlCreateButton("删除配置", 20, 134, 68, 30, $BS_FLAT)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$group2 = GUICtrlCreateGroup("系统当前IP配置", 280, 15, 210, 165)
Local $index = 3
GUICtrlCreateLabel("I P 地址:", 295, 35, 60, 15)
$System_IPAddress = _GUICtrlIpAddress_Create($mainwindow, 355, 32, 125, 20, $WS_CHILD)
GUICtrlCreateLabel("子网掩码:", 295, 63, 60, 15)
$System_Subnetmask = _GUICtrlIpAddress_Create($mainwindow, 355, 60, 125, 20, $WS_CHILD)
GUICtrlCreateLabel("默认网关:", 295, 91, 60, 15)
$System_Gateway = _GUICtrlIpAddress_Create($mainwindow, 355, 88, 125, 20, $WS_CHILD)
GUICtrlCreateLabel("默认DNS1:", 295, 119, 60, 15)
$System_Dns1 = _GUICtrlIpAddress_Create($mainwindow, 355, 115, 125, 20, $WS_CHILD)
GUICtrlCreateLabel("默认DNS2:", 295, 147, 60, 15)
$System_Dns2 = _GUICtrlIpAddress_Create($mainwindow, 355, 143, 125, 20, $WS_CHILD)
_CurrentIPConfig()
GUICtrlCreateGroup("", -99, -99, 1, 1)

$group3 = GUICtrlCreateGroup($SectionNames & "IP配置", 10, 190, 255, 165)
Local $index = 3
GUICtrlCreateLabel("I P 地址:", 40, 220, 60, 15)
$CurrentConfiguration_IPAddress = _GUICtrlIpAddress_Create($mainwindow, 115, 215, 125, 20, $WS_CHILD)
GUICtrlCreateLabel("子网掩码:", 40, 245, 60, 15)
$CurrentConfiguration_Subnetmask = _GUICtrlIpAddress_Create($mainwindow, 115, 240, 125, 20, $WS_CHILD)
GUICtrlCreateLabel("默认网关:", 40, 270, 60, 15)
$CurrentConfiguration_Gateway = _GUICtrlIpAddress_Create($mainwindow, 115, 265, 125, 20, $WS_CHILD)
GUICtrlCreateLabel("默认DNS1:", 40, 295, 60, 15)
$CurrentConfiguration_Dns1 = _GUICtrlIpAddress_Create($mainwindow, 115, 290, 125, 20, $WS_CHILD)
GUICtrlCreateLabel("默认DNS2:", 40, 320, 60, 15)
$CurrentConfiguration_Dns2 = _GUICtrlIpAddress_Create($mainwindow, 115, 315, 125, 20, $WS_CHILD)
_CurrentIPConfiguration($SectionNames)
GUICtrlCreateGroup("", -99, -99, 1, 1)

$group4 = GUICtrlCreateGroup("版权信息 - 使用说明", 280, 190, 210, 165)
    GUICtrlCreateLabel("使用说明:" _
      & @CRLF & "    有时候我们的电脑经常在不同的网络环境中使用,每回都要重复、烦琐地配置TCP/IP属性来切换IP。为了方便的切换IP特编写本程序。" _
      & "本程序适合于常在网通、电信、教育网间切换的电脑使用的,或使用本本在公司、家庭游走办公的游走一族。",290,210,195,100)
      GUICtrlCreateLabel("版权所有[&C] 2008 ㊣版技术联合·综合群" & @CRLF,290,315,195,15)
      $label_url =GUICtrlCreateLabel("http://www.Sunny.com",290,330,175,20)
    GUICtrlSetFont(-1,9,-1,4)
    GUICtrlSetCursor (-1, 0)
GUICtrlCreateGroup("", -99, -99, 1, 1)

GUISetState(@SW_SHOW)


$mouseon = 0 ;鼠标经过控件的标记
While 1
      $nMsg = GUIGetMsg()
      Switch $nMsg
                Case $GUI_EVENT_CLOSE    ;关闭程序
                        DllCall("user32.dll", "int", "AnimateWindow", "hwnd", $mainwindow, "int", 500, "long", 0x00090000)
                        Exit
                Case $setip            ;切换IP
                        $SectionNames = GUICtrlRead($List1)
                        _setip($SectionNames)
                        _CurrentIPConfig()
                Case $config             ;修改IP方案
                        $SectionNames = GUICtrlRead($List1)
                        _configIP($SectionNames)
                Case $Add               ;添加IP方案
                        _AddIP()
                Case $Delete            ;删除IP方案
                        $SectionNames = GUICtrlRead($List1)
                        _DeleteIP($SectionNames)
                        $SectionNames = GUICtrlRead($List1)
                        _CurrentIPConfiguration($SectionNames)
                Case $List1             ;显示选中的IP配置
                        $SectionNames = GUICtrlRead($List1)
                        _CurrentIPConfiguration($SectionNames)
      EndSwitch
      $mousepos = GUIGetCursorInfo($mainwindow)
      If $mousepos == $label_url Then
                If $mouseon Then
                  $mouseon = 0
                        GUICtrlSetPos($label_url,292,328,175,20)
                        GUICtrlSetColor($label_url,0x0000FF)
                EndIf
            If$mousepos Then
                        Run(@ProgramFilesDir & "\Internet Explorer\IEXPLORE.EXE http://group.qq.com/group_index.shtml?groupid=18115990")
                        Sleep(100)
                EndIf
      Else
                If Not $mouseon Then
                        $mouseon = 1
                        GUICtrlSetPos($label_url,290,330,175,20)
                  GUICtrlSetColor($label_url,0x000000)         
                EndIf
      EndIf
WEnd


Func _CreatFile()
      If Not FileExists(@ScriptDir & "\IP Configlist.ini") Then
                Dim $Configuration1 = [ [ "IPAddress", "192.168.1.66" ], [ "SubnetMask", "255.255.255.0" ], ["Gateway", "192.168.1.1"], ["DNSServer1", "202.96.209.5"], ["DNSServer2", "202.96.199.133"] ]
                IniWriteSection("IP Configlist.ini", "公司", $Configuration1, 0)
                Dim $Configuration2 = [ [ "IPAddress", "10.10.22.30" ], [ "SubnetMask", "255.255.255.0" ], ["Gateway", "10.10.22.1"], ["DNSServer1", "202.117.112.2"], ["DNSServer2", "218.30.19.6"] ]
                IniWriteSection("IP Configlist.ini", "家里", $Configuration2, 0)
                Dim $Configuration3 = [ [ "IPAddress", "192.168.1.201" ], [ "SubnetMask", "255.255.255.0" ], ["Gateway", "192.168.1.1"], ["DNSServer1", "61.134.1.3"], ["DNSServer2", "61.134.1.20"] ]
                IniWriteSection("IP Configlist.ini", "电信", $Configuration3, 0)
                Dim $Configuration4 = [ [ "IPAddress", "202.236.105.28" ], [ "SubnetMask", "255.255.255.0" ], ["Gateway", "202.236.123.1"], ["DNSServer1", "202.117.112.4"], ["DNSServer2", "218.30.19.44"] ]
                IniWriteSection("IP Configlist.ini", "网通", $Configuration4, 0)
                Dim $Configuration5 = [ [ "IPAddress", "10.10.22.105" ], [ "SubnetMask", "255.255.255.0" ], ["Gateway", "10.10.22.1"], ["DNSServer1", "202.117.112.1"], ["DNSServer2", "218.30.19.38"] ]
                IniWriteSection("IP Configlist.ini", "教育网", $Configuration5, 0)
      EndIf
EndFunc   ;==>_CreatFile

Func _CurrentIPConfig() ;显示当前系统IP配置
      $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
      $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = TRUE", "WQL",$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
      $colComputers = $objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
      For $objItem In $colItems
                $LocalIP = $objItem.IPAddress (0)
                $LocalSubnetmask = $objItem.IPSubnet (0)
                $LocalGateway = $objItem.DefaultIPGateway (0)
                $LocalDns1 = $objItem.DNSServerSearchOrder (0)
                $LocalDns2 = $objItem.DNSServerSearchOrder (1)
      Next
      _GUICtrlIpAddress_Set($System_IPAddress, $LocalIP)
      _GUICtrlIpAddress_Set($System_Subnetmask, $LocalSubnetmask)
      _GUICtrlIpAddress_Set($System_Gateway, $LocalGateway)
      _GUICtrlIpAddress_Set($System_Dns1, $LocalDns1)
      _GUICtrlIpAddress_Set($System_Dns2, $LocalDns2)
EndFunc   ;==>_CurrentIPConfig

Func _setip($SectionNames = "")   ;设置系统 IP配置
      Dim $SetIPAddress
      $SetIPAddress = IniRead(@ScriptDir & "\IP Configlist.ini", $SectionNames, "IPAddress", "")
      Dim $SetSubnetmask
      $SetSubnetmask = IniRead(@ScriptDir & "\IP Configlist.ini", $SectionNames, "SubnetMask", "")
      Dim $SetGateway
      $SetGateway = IniRead(@ScriptDir & "\IP Configlist.ini", $SectionNames, "Gateway", "")
      Dim $SetDns
      $SetDns = IniRead(@ScriptDir & "\IP Configlist.ini", $SectionNames, "DNSServer1", "")
      $SetDns = IniRead(@ScriptDir & "\IP Configlist.ini", $SectionNames, "DNSServer2", "")
      TrayTip("提醒", "正在设置IP,请稍等...", 1)
      $objWMIService = ObjGet("winmgmts:\" & $strComputer & "\root\CIMV2")
      $colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = TRUE", "WQL", $wbemFlagReturnImmediately + $wbemFlagForwardOnly)
      $colComputers = $objWMIService.ExecQuery ("Select * from Win32_ComputerSystem")
      If IsObj($colItems) Then
                For $objNetAdapter In $colItems
                        $objNetAdapter.EnableStatic ($SetIPAddress, $SetSubnetmask)
                        $objNetAdapter.SetGateways ($SetGateway)
                        $objNetAdapter.SetDNSServerSearchOrder ($SetDns)
                Next
      EndIf
      TrayTip("提醒", "IP设置完成" & @CRLF & "I P 地址:" & $SetIPAddress & @CRLF & "子网掩码:" & $SetSubnetmask & @CRLF & "网    关:" _
                         & $SetGateway & @CRLF & "默认DNS1:" & $SetDns & @CRLF & "默认DNS2:" & $SetDns, 1)
EndFunc   ;==>_setip

Func _configIP($OldSectionName = "")   ;修改配置
;~               GUISetState(@SW_DISABLE,$mainwindow)
      $IPAddress = IniRead(@ScriptDir & "\IP Configlist.ini", $OldSectionName, "IPAddress", "")
      $Subnetmask = IniRead(@ScriptDir & "\IP Configlist.ini", $OldSectionName, "SubnetMask", "")
      $Gateway = IniRead(@ScriptDir & "\IP Configlist.ini", $OldSectionName, "Gateway", "")
      Dim $Dns
      $Dns = IniRead(@ScriptDir & "\IP Configlist.ini", $OldSectionName, "DNSServer1", "")
      $Dns = IniRead(@ScriptDir & "\IP Configlist.ini", $OldSectionName, "DNSServer2", "")
      $configwindow = GUICreate("修改IP配置", 225, 270, @DesktopWidth / 2 - 225 / 2, @DesktopHeight / 2 - 230 / 2)
      $group2 = GUICtrlCreateGroup($OldSectionName & "IP配置", 10, 15, 205, 175)
      Local $index = 3
      GUICtrlCreateLabel("I P 地址:", 20, 35, 60, 15)
      $config_IPAddress = _GUICtrlIpAddress_Create($configwindow, 80, 33, 125, 20, $WS_CHILD)
      _GUICtrlIpAddress_Set($config_IPAddress, $IPAddress)
      GUICtrlCreateLabel("子网掩码:", 20, 60, 60, 15)
      $config_Subnetmask = _GUICtrlIpAddress_Create($configwindow, 80, 57, 125, 20, $WS_CHILD)
      _GUICtrlIpAddress_Set($config_Subnetmask, $Subnetmask)
      GUICtrlCreateLabel("默认网关:", 20, 85, 60, 15)
      $config_Gateway = _GUICtrlIpAddress_Create($configwindow, 80, 80, 125, 20, $WS_CHILD)
      _GUICtrlIpAddress_Set($config_Gateway, $Gateway)
      GUICtrlCreateLabel("默认DNS1:", 20, 110, 60, 15)
      $config_Dns1 = _GUICtrlIpAddress_Create($configwindow, 80, 105, 125, 20, $WS_CHILD)
      _GUICtrlIpAddress_Set($config_Dns1, $Dns)
      GUICtrlCreateLabel("默认DNS2:", 20, 135, 60, 15)
      $config_Dns2 = _GUICtrlIpAddress_Create($configwindow, 80, 130, 125, 20, $WS_CHILD)
      _GUICtrlIpAddress_Set($config_Dns2, $Dns)
      GUICtrlCreateLabel("配置名称", 20, 160, 60, 15)
      $rename = GUICtrlCreateInput($SectionNames, 80, 155, 125, 20)
      GUICtrlCreateGroup("", -99, -99, 1, 1)
      $queding = GUICtrlCreateButton("修改", 10, 200, 60, 30)
      $clear = GUICtrlCreateButton("清空", 83, 200, 60, 30)
      $quxiao = GUICtrlCreateButton("取消", 155, 200, 60, 30)
      GUISetState()
      While 1
                $cmsg = GUIGetMsg(1)
                Switch $cmsg
                        Case $queding
                              $IPAddress = _GUICtrlIpAddress_Get($config_IPAddress)
                              $Subnetmask = _GUICtrlIpAddress_Get($config_Subnetmask)
                              $Gateway = _GUICtrlIpAddress_Get($config_Gateway)
                              $Dns = _GUICtrlIpAddress_Get($config_Dns1)
                              $Dns = _GUICtrlIpAddress_Get($config_Dns2)
                              $NewSectionName = GUICtrlRead($rename)
                              Dim $Configuration = [ [ "IPAddress", $IPAddress ], [ "SubnetMask", $Subnetmask ], ["Gateway", $Gateway], ["DNSServer1", $Dns], ["DNSServer2", $Dns] ]
                              If ($OldSectionName <> $NewSectionName) And (Not IniRenameSection(@ScriptDir & "\IP Configlist.ini", $OldSectionName, $NewSectionName, 0)) Then
                                        $selete = MsgBox(36, "确认配置替换", "配置“" & $NewSectionName & "”已存在,是否替换?")
                                        If $selete == 6 Then
                                                IniRenameSection(@ScriptDir & "\IP Configlist.ini", $OldSectionName, $NewSectionName, 1)
                                        Else
                                                ContinueLoop
                                        EndIf
                              EndIf
                              IniWriteSection(@ScriptDir & "\IP Configlist.ini", $NewSectionName, $Configuration, 0)
                              GUICtrlSetData($List1, "", "")
                              $SectionNames = IniReadSectionNames(@ScriptDir & "\IP Configlist.ini")
                              For $i = 1 To $SectionNames
                                        GUICtrlSetData($List1, $SectionNames[$i], $NewSectionName)
                              Next
                              _CurrentIPConfiguration($NewSectionName)
                              ExitLoop
                        Case $clear
                              _GUICtrlIpAddress_Set($config_IPAddress, "0.0.0.0")
                              _GUICtrlIpAddress_Set($config_Subnetmask, "0.0.0.0")
                              _GUICtrlIpAddress_Set($config_Gateway, "0.0.0.0")
                              _GUICtrlIpAddress_Set($config_Dns1, "0.0.0.0")
                              _GUICtrlIpAddress_Set($config_Dns2, "0.0.0.0")
                              GUICtrlSetData($rename, "新IP配置")
                              ContinueLoop
                        Case $quxiao
                              ExitLoop
                        Case $GUI_EVENT_CLOSE
                              If $cmsg == $configwindow Then
                                        ExitLoop
                              EndIf
                EndSwitch
      WEnd
      GUIDelete($configwindow)
;~                         GUISetState(@SW_ENABLE,$mainwindow)
      If Not WinActive($mainwindow) Then
                WinActivate($mainwindow)
      EndIf
EndFunc   ;==>_configIP

Func _AddIP()       ;添加配置
;~                         GUISetState(@SW_DISABLE,$mainwindow)
      $Addwindow = GUICreate("添加IP配置", 225, 270, @DesktopWidth / 2 - 225 / 2, @DesktopHeight / 2 - 230 / 2)
      $group2 = GUICtrlCreateGroup("新IP配置", 10, 15, 205, 175)
      Local $index = 3
      GUICtrlCreateLabel("I P 地址:", 20, 35, 60, 15)
      $config_IPAddress = _GUICtrlIpAddress_Create($Addwindow, 80, 33, 125, 20, $WS_CHILD)
      GUICtrlCreateLabel("子网掩码:", 20, 60, 60, 15)
      $config_Subnetmask = _GUICtrlIpAddress_Create($Addwindow, 80, 57, 125, 20, $WS_CHILD)
      GUICtrlCreateLabel("默认网关:", 20, 85, 60, 15)
      $config_Gateway = _GUICtrlIpAddress_Create($Addwindow, 80, 80, 125, 20, $WS_CHILD)
      GUICtrlCreateLabel("默认DNS1:", 20, 110, 60, 15)
      $config_Dns1 = _GUICtrlIpAddress_Create($Addwindow, 80, 105, 125, 20, $WS_CHILD)
      GUICtrlCreateLabel("默认DNS2:", 20, 135, 60, 15)
      $config_Dns2 = _GUICtrlIpAddress_Create($Addwindow, 80, 130, 125, 20, $WS_CHILD)
      GUICtrlCreateLabel("配置名称", 20, 160, 60, 15)
      $rename = GUICtrlCreateInput("新IP配置", 80, 155, 125, 20)
      GUICtrlCreateGroup("", -99, -99, 1, 1)
      $queding = GUICtrlCreateButton("添加", 10, 200, 60, 30)
      $reset = GUICtrlCreateButton("重置", 83, 200, 60, 30)
      $quxiao = GUICtrlCreateButton("取消", 155, 200, 60, 30)
      GUISetState()
      While 1
                $amsg = GUIGetMsg(1)
                Switch $amsg
                        Case $queding
                              $IPAddress = _GUICtrlIpAddress_Get($config_IPAddress)
                              $Subnetmask = _GUICtrlIpAddress_Get($config_Subnetmask)
                              $Gateway = _GUICtrlIpAddress_Get($config_Gateway)
                              Dim $Dns
                              $Dns = _GUICtrlIpAddress_Get($config_Dns1)
                              $Dns = _GUICtrlIpAddress_Get($config_Dns2)
                              $NewSectionName = GUICtrlRead($rename)
                              Dim $Configuration = [ [ "IPAddress", $IPAddress ], [ "SubnetMask", $Subnetmask ], ["Gateway", $Gateway], ["DNSServer1", $Dns], ["DNSServer2", $Dns] ]
                              $SectionNames = IniReadSectionNames(@ScriptDir & "\IP Configlist.ini")
                              $flag = 1
                              If $SectionNames == 1 Then
                                        IniWriteSection(@ScriptDir & "\IP Configlist.ini", $NewSectionName, $Configuration, 0)
                              ElseIf $SectionNames <> 1 Then
                                        For $i = 1 To $SectionNames
                                                If $NewSectionName == $SectionNames[$i] Then
                                                      $selete = MsgBox(36, "确认配置替换", "配置“" & $NewSectionName & "”已存在,是否替换?")
                                                      If $selete == 6 Then
                                                                ExitLoop
                                                      ElseIf $selete <> 6 Then
                                                                $flag = 0
                                                                ExitLoop
                                                      EndIf
                                                EndIf
                                        Next
                              EndIf
                              If $flag = 0 Then
                                        ContinueLoop
                              EndIf
                              IniWriteSection(@ScriptDir & "\IP Configlist.ini", $NewSectionName, $Configuration, 0)
                              GUICtrlSetData($List1, "", "")
                              $SectionNames = IniReadSectionNames(@ScriptDir & "\IP Configlist.ini")
                              For $i = 1 To $SectionNames
                                        GUICtrlSetData($List1, $SectionNames[$i], $NewSectionName)
                              Next
                              _CurrentIPConfiguration($NewSectionName)
                              ExitLoop
                        Case $reset
                              _GUICtrlIpAddress_Set($config_IPAddress, "0.0.0.0")
                              _GUICtrlIpAddress_Set($config_Subnetmask, "0.0.0.0")
                              _GUICtrlIpAddress_Set($config_Gateway, "0.0.0.0")
                              _GUICtrlIpAddress_Set($config_Dns1, "0.0.0.0")
                              _GUICtrlIpAddress_Set($config_Dns2, "0.0.0.0")
                              GUICtrlSetData($rename, "新IP配置")
                              ContinueLoop
                        Case $quxiao
                              ExitLoop
                        Case $GUI_EVENT_CLOSE
                              If $amsg == $Addwindow Then
                                        ExitLoop
                              EndIf
                EndSwitch
      WEnd
      GUIDelete($Addwindow)
;~                         GUISetState(@SW_ENABLE,$mainwindow)
      If Not WinActive($mainwindow) Then
                WinActivate($mainwindow)
      EndIf
EndFunc   ;==>_AddIP

Func _DeleteIP($DeleteSectionName = 0);删除选中的配置
      $selete = MsgBox(36, "确认删除", "确实要删除“" & $DeleteSectionName & "”IP配置吗?")
      If $selete == 6 Then
                IniDelete(@ScriptDir & "\IP Configlist.ini", $DeleteSectionName)
                GUICtrlSetData($List1, "", "")
                $SectionNames = IniReadSectionNames(@ScriptDir & "\IP Configlist.ini")
                If $SectionNames <> 1 Then
                        For $i = 1 To $SectionNames
                              GUICtrlSetData($List1, $SectionNames[$i], $SectionNames[$i])
                        Next
                EndIf
      EndIf
      If Not WinActive($mainwindow) Then
                WinActivate($mainwindow)
      EndIf
EndFunc   ;==>_DeleteIP

Func _CurrentIPConfiguration($CurrentSectionName = "")   ;显示选中的配置
      GUICtrlSetData($group3, $CurrentSectionName & "IP配置", "")
      $IPAddress = IniRead(@ScriptDir & "\IP Configlist.ini", $CurrentSectionName, "IPAddress", "")
      $Subnetmask = IniRead(@ScriptDir & "\IP Configlist.ini", $CurrentSectionName, "SubnetMask", "")
      $Gateway = IniRead(@ScriptDir & "\IP Configlist.ini", $CurrentSectionName, "Gateway", "")
      Dim $Dns
      $Dns = IniRead(@ScriptDir & "\IP Configlist.ini", $CurrentSectionName, "DNSServer1", "")
      $Dns = IniRead(@ScriptDir & "\IP Configlist.ini", $CurrentSectionName, "DNSServer2", "")
      _GUICtrlIpAddress_Set($CurrentConfiguration_IPAddress, $IPAddress)
      _GUICtrlIpAddress_Set($CurrentConfiguration_Subnetmask, $Subnetmask)
      _GUICtrlIpAddress_Set($CurrentConfiguration_Gateway, $Gateway)
      _GUICtrlIpAddress_Set($CurrentConfiguration_Dns1, $Dns)
      _GUICtrlIpAddress_Set($CurrentConfiguration_Dns2, $Dns)
EndFunc   ;==>_CurrentIPConfiguration

lxz 发表于 2010-2-6 18:05:36

哪里出错?......

316428696 发表于 2010-2-7 00:18:16

请大家帮忙看下这源码,出错,谢
迷失左岸 发表于 2010-2-6 17:39 http://www.autoitx.com/images/common/back.gif


    代码没出错啊!

316428696 发表于 2010-2-7 00:18:33

是不是更换IP地址的时候出错?

迷失左岸 发表于 2010-2-7 09:16:51

是的,在切换配置的时候会出错,帮忙各位改下,谢

xyold1 发表于 2010-2-7 12:11:10

我也写了个改mac 和ip 的,不过重启网卡不太理想,谁有好的重启网卡的办法啊

迷失左岸 发表于 2010-2-8 09:41:28

没人帮解决,郁闷.................

kswdiy 发表于 2010-2-8 14:44:53

我自己也写了 个 呵呵跟你们类似的呵呵
呵呵后!!

kswdiy 发表于 2010-2-8 14:46:42

我自己写的 是通用于 PE和Xp/2003的都能运行的 所以回有一些不同呵呵呵。。。。

kswdiy 发表于 2010-2-8 14:48:47

这个不是你写的把??

kswdiy 发表于 2010-2-8 14:49:23

这个我在自由天空 看过你 这个代码 呵呵。。。

nmgwddj 发表于 2010-2-8 14:59:23

代码最好贴出来。要么我们下还得要钢镚!

rikthhpgf2005 发表于 2010-2-8 18:04:59

粘上去看的人多点:face (37):

迷失左岸 发表于 2010-2-9 10:56:13

粘上去了,请大家帮忙解决一下.

迷失左岸 发表于 2010-2-27 14:31:29

怎么就没没人帮我解决这个问题呢,哎,郁闷中.........
页: [1] 2
查看完整版本: IP地址随意换