#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
$form=GUICreate("服务器监控",600,320)
GUISetState(@SW_SHOW)
Local $path
$path=@ScriptDir & "\server.ini"
$search=FileFindFirstFile($path)
If $search= -1 Then
MsgBox(0,"警告","软件的配置文件不存在")
Exit
EndIf
$inifeil=@ScriptDir & "\server.ini"
$a=IniRead($inifeil,"服务器地址" ,"服务器名","")
$a1=IniRead($inifeil,"服务器地址" ,"IP地址","")
$a2=IniRead($inifeil,"服务器地址" ,"端口","")
$a3=IniRead($inifeil,"服务器地址1" ,"服务器名","")
$a4=IniRead($inifeil,"服务器地址1" ,"IP地址","")
$a5=IniRead($inifeil,"服务器地址1" ,"端口","")
$a6=IniRead($inifeil,"服务器地址2" ,"服务器名","")
$a7=IniRead($inifeil,"服务器地址2" ,"IP地址","")
$a8=IniRead($inifeil,"服务器地址2" ,"端口","")
$a9=IniRead($inifeil,"服务器地址3" ,"服务器名","")
$b1=IniRead($inifeil,"服务器地址3" ,"IP地址","")
$b2=IniRead($inifeil,"服务器地址3" ,"端口","")
$b3=IniRead($inifeil,"服务器地址4" ,"服务器名","")
$b4=IniRead($inifeil,"服务器地址4" ,"IP地址","")
$b5=IniRead($inifeil,"服务器地址4" ,"端口","")
$b6=IniRead($inifeil,"服务器地址5" ,"服务器名","")
$b7=IniRead($inifeil,"服务器地址5" ,"IP地址","")
$b8=IniRead($inifeil,"服务器地址5" ,"端口","")
$b9=IniRead($inifeil,"服务器地址6" ,"服务器名","")
$ab=IniRead($inifeil,"服务器地址6" ,"IP地址","")
$ab2=IniRead($inifeil,"服务器地址6" ,"端口","")
GUICtrlCreateLabel("服务器名",50,20,50,20)
GUICtrlCreateLabel("IP地址",220,20,50,20)
GUICtrlCreateLabel("端口",380,20,30,20)
GUICtrlCreateLabel("网络状态",480,20,50,20)
GUICtrlCreateInput(@ComputerName,30,270,100,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
GUICtrlCreateInput(@IPAddress1,210,270,100,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
GUICtrlCreateInput(@IPAddress2,380,270,100,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
GUICtrlCreateInput($a,10,40,130,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
GUICtrlCreateInput($a1,180,40,130,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
GUICtrlCreateInput($a2,360,40,70,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
$input=GUICtrlCreateInput("",470,40,100,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
GUICtrlCreateInput($a3,10,70,130,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
GUICtrlCreateInput($a4,180,70,130,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
GUICtrlCreateInput($a5,360,70,70,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
$input2=GUICtrlCreateInput("",470,70,100,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
GUICtrlCreateInput($a6,10,100,130,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
GUICtrlCreateInput($a7,180,100,130,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
GUICtrlCreateInput($a8,360,100,70,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
$input3=GUICtrlCreateInput("",470,100,100,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
GUICtrlCreateInput($a9,10,130,130,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
GUICtrlCreateInput($b1,180,130,130,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
GUICtrlCreateInput($b2,360,130,70,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
$input4=GUICtrlCreateInput("",470,130,100,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
GUICtrlCreateInput($b3,10,160,130,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
GUICtrlCreateInput($b4,180,160,130,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
GUICtrlCreateInput($b5,360,160,70,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
$input5=GUICtrlCreateInput("",470,160,100,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
GUICtrlCreateInput($b6,10,190,130,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
GUICtrlCreateInput($b7,180,190,130,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
GUICtrlCreateInput($b8,360,190,70,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
$input6=GUICtrlCreateInput("",470,190,100,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
GUICtrlCreateInput($b9,10,220,130,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
GUICtrlCreateInput($ab,180,220,130,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
GUICtrlCreateInput($ab2,360,220,70,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
$input7=GUICtrlCreateInput("",470,220,100,20,BitOR($ES_CENTER,$ES_AUTOHSCROLL,$ES_READONLY,$WS_BORDER))
Check_TCP_PORT()
;===========检查TCP端口是否打开================
Func Check_TCP_PORT()
$i=2
While $i < 10
sleep(1000)
TCPStartUp()
$socket = TCPConnect($a1,$a2)
If $socket=-1 Then
ping($a1)
switch @error
case 0
GUICtrlSetData ($input2,"端口不正确")
case 1
GUICtrlSetData($input2,"无法连接端口")
case 2
GUICtrlSetData($input2,"网络不可达")
Case 3
GUICtrlSetData($input2,"错误目的地")
Case 4
GUICtrlSetData($input2,"未知错误")
EndSwitch
else
GUICtrlSetData($input2,"网络正常")
EndIf
TCPShutdown()
WEnd
EndFunc ;>=结束程序
While 1
$msg=GUIGetMsg()
Select
Case $msg=$GUI_EVENT_CLOSE
Exit
EndSelect
WEnd
配置文件是: