|
楼主 |
发表于 2010-8-14 07:22:21
|
显示全部楼层
附上代码
本帖最后由 cutyourchicken 于 2010-8-14 09:31 编辑
客户端的:#include <String.au3>
#include <GUIConstantsEx.au3>
If Not FileExists(@ScriptDir&""&"Client.ini") Then
MsgBox(0+16,"错误:","配置文件丢失!",20,"")
Exit
EndIf
$SVRIP= IniRead(@ScriptDir&""&"Client.ini","Config","Server","")
$Port= IniRead(@ScriptDir&""&"Client.ini","Config","Port","")
$_IfTable=_GetIfTable()
Global $_Down=$_IfTable[0]
Global $_UpDate=$_IfTable[1]
TCPStartup()
While 1
Sleep(1000)
_Strat_Time()
WEnd
Func _Strat_Time()
$_IfTable=_GetIfTable()
$r_up= "+"&@ComputerName&","&@IPAddress1&","&"在线"&","&Round(($_IfTable[0]-$_Down)/1024,2)&"KB/S"&","&Round(($_IfTable[1]-$_UpDate)/1024,2)&"KB/S"
$go1=StringToBinary($r_up,2)
$socket= TCPConnect($SVRIP,$Port)
If $socket = -1 Then
MsgBox(0+16,"错误:","通讯失败!")
Exit
EndIf
TCPSend($socket,$go1)
Global $_Down=$_IfTable[0]
Global $_UpDate=$_IfTable[1]
EndFunc
Func _GetIfTable()
$_Return=DllCall("Iphlpapi.dll","long","GetIfTable","ptr",0,"ulong*",0,"int",0)
$_aBuffer=DllStructCreate("byte[" & $_Return[2] & "]")
$_Return=DllCall("Iphlpapi.dll","long","GetIfTable","ptr",DllStructGetPtr($_aBuffer),"ulong*",DllStructGetSize($_aBuffer),"int",0)
$_Number=DllStructCreate("dword",DllStructGetPtr($_aBuffer))
$_Number=DllStructGetData($_Number,1)
$_MIB_IFROW="dword" & _StringRepeat(";wchar[256];dword[5];byte[8];dword[16];byte[256]",$_Number)
$_MIB_IFTABLE=DllStructCreate($_MIB_IFROW,DllStructGetPtr($_aBuffer))
Dim $_Table[2]
For $i=2 To $_Number * 5 Step 5
$_Table[0]+=DllStructGetData($_MIB_IFTABLE,$i+3,4)
$_Table[1]+=DllStructGetData($_MIB_IFTABLE,$i+3,10)
Next
Return $_Table
EndFunc
服务端的:#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListView.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#Include <file.au3>
#Include <Array.au3>
Dim $DealData
Dim $HWD[1000]
Dim $DealCom
Dim $DataRip
$Form1_1 = GUICreate("服务端v1.0", 773, 574, 223, 123)
$ListView1 = GUICtrlCreateListView(" 电脑|IP地址|状态|下载速度|上传速度", 18, 8, 737, 497, -1,BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER))
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 0, 100)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 1, 200)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 2, 50)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 3, 200)
GUICtrlSendMsg(-1, $LVM_SETCOLUMNWIDTH, 4, 200)
_GUICtrlListView_JustifyColumn(GUICtrlGetHandle($ListView1), 1, 2)
_GUICtrlListView_JustifyColumn(GUICtrlGetHandle($ListView1), 2, 2)
_GUICtrlListView_JustifyColumn(GUICtrlGetHandle($ListView1), 3, 2)
$Checkbox1 = GUICtrlCreateCheckbox("开机自动运行", 48, 528, 145, 25)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$Checkbox2 = GUICtrlCreateCheckbox("收到消息弹出", 265, 528, 145, 25)
GUICtrlSetState(-1, $GUI_CHECKED)
GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0xFF0000)
$Button1 = GUICtrlCreateButton("设置", 456, 520, 105, 41, -1, BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x008000)
$Button2 = GUICtrlCreateButton("关于", 601, 520, 105, 41, -1, BitOR($WS_EX_CLIENTEDGE,$WS_EX_STATICEDGE))
GUICtrlSetFont(-1, 12, 800, 0, "MS Sans Serif")
GUICtrlSetColor(-1, 0x008000)
$zhucaidan = GUICtrlCreateContextMenu($ListView1)
$yuanchengkongzhi = GUICtrlCreateMenuItem(" 远程控制 ", $zhucaidan)
GUICtrlCreateMenuItem("", $zhucaidan)
$yuanchengzhuomian = GUICtrlCreateMenuItem(" 远程桌面 ", $zhucaidan)
GUICtrlCreateMenuItem("", $zhucaidan)
$wenjianchuanshu = GUICtrlCreateMenuItem(" 文件传输 ", $zhucaidan)
GUICtrlCreateMenuItem("", $zhucaidan)
$jinchengchakan= GUICtrlCreateMenuItem(" 进程查看 ", $zhucaidan)
GUICtrlCreateMenuItem("", $zhucaidan)
$jieshujincheng = GUICtrlCreateMenuItem(" 结束进程 ", $zhucaidan)
GUICtrlCreateMenuItem("", $zhucaidan)
$yunxingchengxu = GUICtrlCreateMenuItem(" 运行程序 ", $zhucaidan)
GUICtrlCreateMenuItem("", $zhucaidan)
$fasongxiaoxi = GUICtrlCreateMenuItem(" 发送消息 ", $zhucaidan)
GUISetState(@SW_SHOW)
If Not FileExists(@ScriptDir&""&"Config.ini") Then
MsgBox(0+16,"错误:","配置文件丢失!","30",$Form1_1)
Exit
EndIf
$serverip = IniRead(@ScriptDir&""&"Config.ini","Feature","ServerIP","")
$ComPort = IniRead(@ScriptDir&""&"Config.ini","Feature","ComPort","")
TCPStartup()
$createskt= TCPListen($serverip,$ComPort)
If $createskt =-1 Then
MsgBox(0+16,"错误:","通讯服务启动失败!",30,$Form1_1)
Exit
EndIf
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
Case $Button1
Case $Button2
EndSwitch
$accskt= TCPAccept($createskt)
$RecData = TCPRecv($accskt,5000000,1)
If $RecData <> "" Then
$DealData=BinaryToString($RecData,2)
$DealCom=StringSplit($DealData,"+",1)
#cs
_FileWriteLog(@ScriptDir&""&"datatransport.log","$DealCom[0]="&$DealCom[0],1)
_FileWriteLog(@ScriptDir&""&"datatransport.log","$DealCom[1]="&$DealCom[1],1)
_FileWriteLog(@ScriptDir&""&"datatransport.log","$DealCom[2]="&$DealCom[2],1)
#ce
$count= 0
For $Num = 1 To $DealCom[0]
$DataRip=StringSplit($DealCom[$Num+1],",",1)
#cs
_FileWriteLog(@ScriptDir&""&"datatransport.log","$DealCom[$Num+1]="&$DealCom[$Num+1],1)
#ce
$get=_GUICtrlListView_GetItemText($ListView1, $Num-1)
$getpre = _GUICtrlListView_GetItemText($ListView1, $count+1)
If $get = $DataRip[1] Then
_FileWriteLog(@ScriptDir&""&"datatransport.log","1if,OK!",1)
_FileWriteLog(@ScriptDir&""&"datatransport.log","$count="&$count,1)
_FileWriteLog(@ScriptDir&""&"datatransport.log","$getpre="&$getpre,1)
_FileWriteLog(@ScriptDir&""&"datatransport.log","$DataRip[1]"&$DataRip[1],1)
_FileWriteLog(@ScriptDir&""&"datatransport.log","$get="&$get,1)
_GUICtrlListView_SetItemText($ListView1,$count,$DataRip[2],1)
_GUICtrlListView_SetItemText($ListView1,$count,$DataRip[3],2)
_GUICtrlListView_SetItemText($ListView1,$count,$DataRip[4],3)
_GUICtrlListView_SetItemText($ListView1,$count,$DataRip[5],4)
ElseIf $get ="" And $getpre <> $DataRip[1] Then
_FileWriteLog(@ScriptDir&""&"datatransport.log","2if,OK!",1)
_GUICtrlListView_AddItem($ListView1,$DataRip[1],"","")
_FileWriteLog(@ScriptDir&""&"datatransport.log","2ADD,OK!",1)
_GUICtrlListView_AddSubItem($ListView1,$count,$DataRip[2],1,"")
_GUICtrlListView_AddSubItem($ListView1,$count,$DataRip[3],2,"")
_GUICtrlListView_AddSubItem($ListView1,$count,$DataRip[4],3,"")
_GUICtrlListView_AddSubItem($ListView1,$count,$DataRip[5],4,"")
Else
If $get<>"" And $get <> $DataRip[1] Then
$count+=1
_FileWriteLog(@ScriptDir&""&"datatransport.log","3if,OK!",1)
If $get <> $DataRip[1] Then
_GUICtrlListView_AddItem($ListView1,$DataRip[1],"","")
_FileWriteLog(@ScriptDir&""&"datatransport.log","3ADD,OK!",1)
$count+=1
EndIf
_GUICtrlListView_AddSubItem($ListView1,$count,$DataRip[2],1,"")
_GUICtrlListView_AddSubItem($ListView1,$count,$DataRip[3],2,"")
_GUICtrlListView_AddSubItem($ListView1,$count,$DataRip[4],3,"")
_GUICtrlListView_AddSubItem($ListView1,$count,$DataRip[5],4,"")
ExitLoop
EndIf
EndIf
$count+=1
If $Num = $DealCom[0]-1 Then ExitLoop
Next
EndIf
WEnd
|
|