找回密码
 加入
搜索
查看: 3879|回复: 5

[网络通信] 关于多线程 【已解决】

[复制链接]
发表于 2010-9-1 23:48:28 | 显示全部楼层 |阅读模式
本帖最后由 haodd 于 2010-11-12 23:22 编辑

类似以下 怎么把配置文件的所有ip 平均交给各个线程 进行ping操作 然后判断ping返回的值。
ping()
配置文件 ini如下
==========================
[ip]
10.1.1.1
10.1.1.2
10.1.1.3
……
……
……
10.1.1.253

[线程]
线程 = 5
==========================
发表于 2010-9-2 11:22:53 | 显示全部楼层
能力有限。花半个小时写的。根据自己需要改改吧。
#NoTrayIcon
If $CmdLine[0] <> 0 Then
$p = Ping($CmdLine[1], 250)
IniWrite("ping.ini", "IP=ping", $CmdLine[1], $p)
exit
endif
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>


$Form1 = GUICreate("AU3局域网群Ping", 510, 420)

dim $Button[256]
$h = 30
$s = 20
for $i = 1 to 255
$Button[$i] = GUICtrlCreateButton($i, $h, $s, 30, 20)
;GUICtrlSetState(-1,$GUI_DISABLE)
$h = $h + 30
if $h > 450 then
$h = 30
$s = $s + 20
endif
next


$Buttona1 = GUICtrlCreateButton("开始", 136, 380, 75, 25)
$Buttona2 = GUICtrlCreateButton("退出", 312, 380, 75, 25)

GUISetState(@SW_SHOW)
While 1
        $nMsg = GUIGetMsg()
        Switch $nMsg
                Case $GUI_EVENT_CLOSE
                        Exit
                case $Buttona1
                        if @Compiled = 1 then
                        p()
                        else
                        msgbox(48,"错误","请编译后再执行此操作!",30,$Form1)
                        endif
                case $Buttona2
                        Exit
        EndSwitch
WEnd

func p()
dim $r[256]
For $i = 1 to 255
$r[$i] = run(@ScriptFullPath&" 192.168.1."&$i)
next
For $i = 1 to 255
ProcessWaitClose($r[$i])
next
For $i = 1 to 255
if IniRead("ping.ini", "IP=ping", "192.168.1."&$i, "") > 0 then GUICtrlSetBkColor($Button[$i], 0x00ff00)
next
endfunc
发表于 2010-9-2 12:11:17 | 显示全部楼层
发表于 2010-9-2 13:42:53 | 显示全部楼层
这不算多线程吧
 楼主| 发表于 2010-9-2 23:55:15 | 显示全部楼层
感谢, 试试先!
发表于 2012-6-12 22:59:37 | 显示全部楼层
留名回看,谢谢
您需要登录后才可以回帖 登录 | 加入

本版积分规则

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

GMT+8, 2024-6-2 20:10 , Processed in 0.082313 second(s), 24 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

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