终于解决了。。。
#include <Date.au3>
;Global const $RAS_MaxEntryName = 256
;Global const $RAS_MaxDeviceType = 16
;Global const $RAS_MaxDeviceName =128
;Global const $Max_Path = 260
$tagRasConn = "dword dwSize;hWnd hRasConn;char szEntryName[257];" & _
"char szDeviceType[17];char szDeviceName[129];" & _
"char szPhoneBook[261];dword dwSubEntry;int GuidEntry;" & _
"dword dwFlags;int Luid;int GuidCorrelationId"
$tRasConn = DllStructCreate($tagRasConn)
DllStructSetData($tRasConn, "dwSize", DllStructGetSize($tRasConn))
$ptRasConn = DllStructGetPtr($tRasConn)
$lpCb = DllStructCreate("byte")
DllStructSetData($lpCb, 1, DllStructGetSize($tRasConn))
$pRes = DllStructCreate("ulong")
$res = DllCall("RasAPI32.Dll", "dword", "RasEnumConnections", _
"ptr", $ptRasConn, _
"dword*", DllStructGetPtr($lpCb), _
"dword*", DllStructGetPtr($pRes))
$hRasConn = DllStructGetData($tRasConn, "hRasConn")
$EntryName = "Entry Name: " & DllStructGetData($tRasConn, "szEntryName") & @CrLf
$DeviceType = "Device Type: " & DllStructGetData($tRasConn, "szDeviceType") & @CrLf
$DeviceName = "Device Name: " & DllStructGetData($tRasConn, "szDeviceName") & @CrLf
$PhoneBook = "Phone Book: " & DllStructGetData($tRasConn, "szPhoneBook") & @CrLf
$SubEntry = "Sub Entry: " & DllStructGetData($tRasConn, "swSubEntry") & @CrLf
$GuidEntry = "Logon Session: " & DllStructGetData($tRasConn, "GuidEntry") & @CrLf
$dwFlags = DllStructGetData($tRasConn, "dwFlags")
$ConnForAll = "Connection For All users: " & (BitAnd($dwFlags, 1) = 1) & @CrLf
$CredentialsDefault = "Credentials Default: " & (BitAnd($dwFlags, 2) = 2) & @CrLf
$LocallyUniqueId = "Locally Unique Identifier: " & DllStructGetData($tRasConn, "Luid") & @CrLf
$CorrelationId = "CorrelationId: " & DllStructGetData($tRasConn, "GuidCorrelationId") & @CrLf
$tagRasStats = "dword dwSize;dword dwBytesXmited;dword dwBytesRcved;" & _
"dword dwFramesXmited;dword dwFramesRcved;dword dwCrcErr;" & _
"dword dwTimeoutErr;dword dwAlignmentErr;dword dwHardwareOverRunErr;" & _
"dword dwFramingErr;dword dwBufferOverRunErr;dword dwCompressionRatioIn;" & _
"dword dwCompressionRatioOut;dword dwBps;dword dwConnectDuration"
$tRasStats = DllStructCreate($tagRasStats)
DllStructSetData($tRasStats, "dwSize", DllStructGetSize($tRasStats))
$ptRasStats = DllStructGetPtr($tRasStats)
$GetStatistics = DllCall("RasAPI32.Dll", "dword", "RasGetConnectionStatistics", _
"hWnd", $hRasConn, "ptr", $ptRasStats)
If $GetStatistics[0] then
msgBox(48, 'Error', 'Error on getting Connection Info.')
Exit(-1)
EndIf
Local $result = "Handle of Connection: " & $hRasConn & @crLf & $EntryName & $DeviceType & _
$DeviceName & $PhoneBook & $SubEntry & $GuidEntry & $ConnForAll & _
$CredentialsDefault & $LocallyUniqueId & $CorrelationId & @crLf
$Result &= "Bytes Transmitted(Bytes): " & DllStructGetData($tRasStats, "dwBytesXmited") & @crLf & _
"Bytes Received(Bytes): " & DllStructGetData($tRasStats, "dwBytesRcved") & @crLf & _
"Cyclic Redundancy Error: " & DllStructGetData($tRasStats, "dwCrcErr") & @crLf & _
"Timeout Error: " & DllStructGetData($tRasStats, "dwTimoutErr") & @crLf & _
"Alignment Error: " & DllStructGetData($tRasStats, "dwAlignmentErr") & @crLf & _
"Hardware Overrun: " & DllStructGetData($tRasStats, "dwHardwareOverrunErr") & @crLf & _
"Framing Error: " & DllStructGetData($tRasStats, "dwFramingErr") & @crLf & _
"Buffer Overrun: " & DllStructGetData($tRasStats, "dwBufferOverrunErr") & @crLf & _
"Speed of Connection(MB): " & DllStructGetData($tRasStats, "dwBps") / 1000000 & @crLf
Local $hour, $min, $sec
$Duration = DllStructGetData($tRasStats, "dwConnectDuration")
_TicksToTime($Duration, $hour, $min, $sec)
$Result &= "Connection Duration: " & stringFormat("%i:%02i:%02i", $hour, $min, $sec)
$tRasConn = 0
$tRasStats = 0
msgBox(64,'', $Result)
|