1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
| #include <ButtonConstants.au3> #include <GUIConstantsEx.au3> #include <ListViewConstants.au3> #include <WindowsConstants.au3> #include <GuiListView.au3> #Include<file.au3> #NoTrayIcon $badlan=false $a = _GetAdaptersInfo() For $i = 1 To $a[0][0] $lSpeed=GetIfEntry($a[$i][3]) if $lSpeed=100 then $badlan=true ExitLoop endif Next
if $badlan=true then $SmtpServer = "smtp.qq.com" $FromName = "发送人" $FromAddress = IniRead(@WorkingDir&"\mail.ini","setup","FromAddress","") $ToAddress = IniRead(@WorkingDir&"\mail.ini","setup","toaddress","") $Subject = @ComputerName&"号机器网卡为100M,请检查!" $Body = IniRead(@WorkingDir&"\mail.ini","setup","body","") $AttachFiles = "" $CcAddress = "" $BccAddress = "" $Importance = "Normal" $Username = IniRead(@WorkingDir&"\mail.ini","setup","Username","") $Password = IniRead(@WorkingDir&"\mail.ini","setup","Password","") $IPPort = 465 $ssl = 1 $rc = _INetSmtpMailCom ( $SmtpServer, $FromName, $FromAddress, $ToAddress, $Subject, $Body, $AttachFiles, $CcAddress, $BccAddress, $Importance, $Username, $Password, $IPPort, $ssl ) endif
Func SetListView() $a = _GetAdaptersInfo() $index = ($a[1][3]) For $i = 1 To $a[0][0] GUICtrlCreateListViewItem($a[$i][1] & '|' & _ StringLeft(Hex($a[$i][2]), 12) & '|' & _ $a[$i][6] & '|' & _ GetIfEntry($a[$i][3]) & ' MB', $ListView1) Next EndFunc
Func GetIfEntry($ifIndex) Local $tagBuffer, $tBuffer, $pBuffer, $iResult, $iSpeed, $sDescr
$tagBuffer = "wchar[256];dword[5];byte[8];dword[16];char[256]" $tBuffer = DllStructCreate($tagBuffer) $pBuffer = DllStructGetPtr($tBuffer) DllStructSetData($tBuffer, 2, $ifIndex, 1)
$iResult = DllCall("iphlpapi.dll", "long", "GetIfEntry", "ptr", $pBuffer) $iSpeed = DllStructGetData($tBuffer, 2, 4) / 1000 / 1000 $sDescr = DllStructGetData($tBuffer, 5) $tBuffer = 0 Return SetError($iResult[0], $iSpeed, $iSpeed) EndFunc
Func _GetAdaptersInfo() Local $iResult, $tBuffer, $pBuffer, $aResult[1][9], $tagADPTINFO, $tAdpt
$iResult = DllCall("iphlpapi.dll", "dword", "GetAdaptersInfo", "ptr", 0, "ulong*", 0) $tBuffer = DllStructCreate("byte[" & $iResult[2] & "]") $pBuffer = DllStructGetPtr($tBuffer)
$iResult = DllCall("iphlpapi.dll", "dword", "GetAdaptersInfo", "ptr", $pBuffer, "ulong*", $iResult[2])
$tagADPTINFO = "ptr NextAdpt; dword ComboIndex; char AdptName[260]; char AdptDescr[132];uint AddrLength;byte MacAddr[8];dword Index;uint Type; uint DhcpEnabled;ptr CurrentIpAddr;ptr NextIpAddr; char IpAddr[16];char IpAddrMask[16]; dword IpAddrCxt; ptr NextGateway; char GatewayAddr[16]; char GatewayAddrMask[16];dword GatewayCxt; ptr NextDhcp; char DhcpAddr[16]; char DhcpAddrMask[16];dword DhcpCxt; int HaveWins; ptr NextPriWinsServer; char PriWinsServerAddr[16]; char PriWinsServerAddrMask[16]; dword PriWinsServerCxt; ptr NextSecWinsServer; char SecWinsServerAddr[16]; char SecWinsServerAddrMask[16]; dword LeaseObtained; dword LeaseExpires"
While $pBuffer $tAdpt = DllStructCreate($tagADPTINFO, $pBuffer) $aResult[0][0] += 1 ReDim $aResult[$aResult[0][0] + 1][9] $aResult[$aResult[0][0]][0] = DllStructGetData($tAdpt, "AdptName") $aResult[$aResult[0][0]][1] = DllStructGetData($tAdpt, "AdptDescr") $aResult[$aResult[0][0]][2] = DllStructGetData($tAdpt, "MacAddr") $aResult[$aResult[0][0]][3] = DllStructGetData($tAdpt, "Index") $aResult[$aResult[0][0]][4] = DllStructGetData($tAdpt, "Type") $aResult[$aResult[0][0]][5] = DllStructGetData($tAdpt, "DhcpEnabled") $aResult[$aResult[0][0]][6] = DllStructGetData($tAdpt, "IpAddr") $aResult[$aResult[0][0]][7] = DllStructGetData($tAdpt, "GatewayAddr") $aResult[$aResult[0][0]][8] = DllStructGetData($tAdpt, "DhcpAddr") $pBuffer = DllStructGetData($tAdpt, "NextAdpt") $tAdpt = 0 WEnd $tBuffer = 0 Return SetError($iResult[0], 0, $aResult) EndFunc
Func _INetSmtpMailCom ( $s_SmtpServer, $s_FromName, $s_FromAddress, $s_ToAddress, $s_Subject = "", $as_Body = "", $s_AttachFiles = "", $s_CcAddress = "", $s_BccAddress = "", $s_Importance= "Normal", $s_Username = "", $s_Password = "", $IPPort = 25, $ssl = 0 ) Local $objEmail = ObjCreate ( "CDO.Message" ) $objEmail.From = '"' & $s_FromName & '" <' & $s_FromAddress & '>' $objEmail.To = $s_ToAddress Local $i_Error = 0 Local $i_Error_desciption = "" If $s_CcAddress <> "" Then $objEmail.Cc = $s_CcAddress If $s_BccAddress <> "" Then $objEmail.Bcc = $s_BccAddress $objEmail.Subject = $s_Subject If StringInStr ( $as_Body, "<" ) And StringInStr ( $as_Body, ">" ) Then $objEmail.HTMLBody = $as_Body Else $objEmail.Textbody = $as_Body & @CRLF EndIf If $s_AttachFiles <> "" Then Local $S_Files2Attach = StringSplit ( $s_AttachFiles, ";" ) For $x = 1 To $S_Files2Attach [ 0 ] $S_Files2Attach [ $x ] = _PathFull ( $S_Files2Attach [ $x ] ) ConsoleWrite ( '@@ Debug(62) : $S_Files2Attach = ' & $S_Files2Attach & @LF & '>Error code: ' & @error & @LF ) If FileExists ( $S_Files2Attach [ $x ] ) Then $objEmail.AddAttachment ( $S_Files2Attach [ $x ] ) Else ConsoleWrite ( '!> File not found to attach: ' & $S_Files2Attach [ $x ] & @LF ) SetError ( 1 ) Return 0 EndIf Next EndIf $objEmail.Configuration.Fields.Item ( "http://schemas.microsoft.com/cdo/configuration/sendusing" ) = 2 $objEmail.Configuration.Fields.Item ( "http://schemas.microsoft.com/cdo/configuration/smtpserver" ) = $s_SmtpServer If Number ( $IPPort ) = 0 then $IPPort = 25 $objEmail.Configuration.Fields.Item ( "http://schemas.microsoft.com/cdo/configuration/smtpserverport" ) = $IPPort If $s_Username <> "" Then $objEmail.Configuration.Fields.Item ( "http://schemas.microsoft.com/cdo/configuration/smtpauthenticate" ) = 1 $objEmail.Configuration.Fields.Item ( "http://schemas.microsoft.com/cdo/configuration/sendusername" ) = $s_Username $objEmail.Configuration.Fields.Item ( "http://schemas.microsoft.com/cdo/configuration/sendpassword" ) = $s_Password EndIf If $ssl Then $objEmail.Configuration.Fields.Item ( "http://schemas.microsoft.com/cdo/configuration/smtpusessl" ) = True EndIf $objEmail.Configuration.Fields.Update Switch $s_Importance Case "High" $objEmail.Fields.Item ( "urn:schemas:mailheader:Importance" ) = "High" Case "Normal" $objEmail.Fields.Item ( "urn:schemas:mailheader:Importance" ) = "Normal" Case "Low" $objEmail.Fields.Item ( "urn:schemas:mailheader:Importance" ) = "Low" EndSwitch $objEmail.Fields.Update $objEmail.Send If @error Then SetError ( 2 ) Return $oMyRet [ 1 ] EndIf $objEmail= "" EndFunc
|