找回密码
 加入
搜索
查看: 1187|回复: 3

为什么运行时会错误呢?

[复制链接]
发表于 2009-11-27 21:22:34 | 显示全部楼层 |阅读模式
购买主题 已有 1 人购买  本主题需向作者支付 10 块金钱 才能浏览
发表于 2009-11-27 23:05:11 | 显示全部楼层
#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[0] 
                GUICtrlSetData($List1, $SectionNames[$i], $SectionNames[1]) 
        Next 
Else 
        Dim $SectionNames[2] 
        $SectionNames[1] = "" 
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[1] & "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[1]) 
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[4] == $label_url Then 
                If $mouseon Then 
                    $mouseon = 0 
                        GUICtrlSetPos($label_url,292,328,175,20) 
                        GUICtrlSetColor($label_url,0x0000FF) 
                EndIf 
            If  $mousepos[2] 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[5][2] = [ [ "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[5][2] = [ [ "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[5][2] = [ [ "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[5][2] = [ [ "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[5][2] = [ [ "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[1] 
        $SetIPAddress[0] = IniRead(@ScriptDir & "\IP Configlist.ini", $SectionNames, "IPAddress", "") 
        Dim $SetSubnetmask[1] 
        $SetSubnetmask[0] = IniRead(@ScriptDir & "\IP Configlist.ini", $SectionNames, "SubnetMask", "") 
        Dim $SetGateway[1] 
        $SetGateway[0] = IniRead(@ScriptDir & "\IP Configlist.ini", $SectionNames, "Gateway", "") 
        Dim $SetDns[2] 
        $SetDns[0] = IniRead(@ScriptDir & "\IP Configlist.ini", $SectionNames, "DNSServer1", "") 
        $SetDns[1] = 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[0] & @CRLF & "子网掩码:" & $SetSubnetmask[0] & @CRLF & "网    关:" _ 
                         & $SetGateway[0] & @CRLF & "默认DNS1:" & $SetDns[0] & @CRLF & "默认DNS2:" & $SetDns[1], 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[2] 
        $Dns[0] = IniRead(@ScriptDir & "\IP Configlist.ini", $OldSectionName, "DNSServer1", "") 
        $Dns[1] = 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[0]) 
        GUICtrlCreateLabel("默认DNS2:", 20, 135, 60, 15) 
        $config_Dns2 = _GUICtrlIpAddress_Create($configwindow, 80, 130, 125, 20, $WS_CHILD) 
        _GUICtrlIpAddress_Set($config_Dns2, $Dns[1]) 
        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[0] 
                        Case $queding 
                                $IPAddress = _GUICtrlIpAddress_Get($config_IPAddress) 
                                $Subnetmask = _GUICtrlIpAddress_Get($config_Subnetmask) 
                                $Gateway = _GUICtrlIpAddress_Get($config_Gateway) 
                                $Dns[0] = _GUICtrlIpAddress_Get($config_Dns1) 
                                $Dns[1] = _GUICtrlIpAddress_Get($config_Dns2) 
                                $NewSectionName = GUICtrlRead($rename) 
                                Dim $Configuration[5][2] = [ [ "IPAddress", $IPAddress ], [ "SubnetMask", $Subnetmask ], ["Gateway", $Gateway], ["DNSServer1", $Dns[0]], ["DNSServer2", $Dns[1]] ] 
                                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[0] 
                                        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[1] == $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[0] 
                        Case $queding 
                                $IPAddress = _GUICtrlIpAddress_Get($config_IPAddress) 
                                $Subnetmask = _GUICtrlIpAddress_Get($config_Subnetmask) 
                                $Gateway = _GUICtrlIpAddress_Get($config_Gateway) 
                                Dim $Dns[2] 
                                $Dns[0] = _GUICtrlIpAddress_Get($config_Dns1) 
                                $Dns[1] = _GUICtrlIpAddress_Get($config_Dns2) 
                                $NewSectionName = GUICtrlRead($rename) 
                                Dim $Configuration[5][2] = [ [ "IPAddress", $IPAddress ], [ "SubnetMask", $Subnetmask ], ["Gateway", $Gateway], ["DNSServer1", $Dns[0]], ["DNSServer2", $Dns[1]] ] 
                                $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[0] 
                                                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[0] 
                                        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[1] == $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[0] 
                                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[2] 
        $Dns[0] = IniRead(@ScriptDir & "\IP Configlist.ini", $CurrentSectionName, "DNSServer1", "") 
        $Dns[1] = 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[0]) 
        _GUICtrlIpAddress_Set($CurrentConfiguration_Dns2, $Dns[1]) 
EndFunc   ;==>_CurrentIPConfiguration

评分

参与人数 1金钱 +20 贡献 +5 收起 理由
afan + 20 + 5

查看全部评分

 楼主| 发表于 2009-11-29 20:57:08 | 显示全部楼层
十分感谢你
发表于 2010-1-19 12:13:52 | 显示全部楼层
205  (File "C:\Documents and Settings\Administrator\桌面\100.au3"):

$colItems = $objWMIService.ExecQuery ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = TRUE", "WQL",
$wbemFlagReturnImmediately + $wbemFlagForwardOnly)
$colItems = $objWMIService^ ERROR

Error: 变量类型必须为对象类型("Object").

还是出错,怎么回事
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-9-21 07:02 , Processed in 0.090385 second(s), 28 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表