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 | IFEX %&CurFile%.LOG, LOGS --2 * %&CurFile%.LOG
ENVI$ &NL=0d 0a
ENVI^ EnviMode=1
ENVI^ ForceLOcal=1
WIN1
_SUB WIN1,W387H254,网络速度,
LABE &wMsg,L63T78W264H100,,,
CALL $--ret:&&hDll ,-LoadLibrary,^Iphlpapi.dll
CALL $--ret:&&GetIfTable ,-GetProcAddress,*%hDll%,GetIfTable
--MESS. [%&hDll%] [%&GetIfTable%]
SET &sz0=0x100000
SET$$ &sz=0x00100000 0 0
SET#$ &Buf=*0x100100 0
SET &dwLastIn=0 //上一秒钟的接收字节数
SET &dwLastOut=0 //上一秒钟的发送字节数
SET &dwBandIn=0 //下载速度
SET &dwBandOut=0 //上传速度
SET &MAX_INTERFACE_NAME_LEN=256
SET &MAXLEN_PHYSADDR=8
SET &MAXLEN_IFDESCR=256
CALC #&&MIBLEN=%&MAX_INTERFACE_NAME_LEN% * 2 + 4*5 + %&MAXLEN_PHYSADDR% + 4*16 + %&MAXLEN_IFDESCR%
CALC #&&Ofb1=4 + %&MAX_INTERFACE_NAME_LEN% * 2 + 4*5 + %&MAXLEN_PHYSADDR% + 4*3
//CALC #&&Ofb2=%&Ofb1% + 4*6
SET &dwInOctets=0
SET &dwOutOctets=0
TIME T1,1000, CALL OnT1
_END
_SUB OnT1
SET-long sz=%&sz0%
SET-int64 Buf=0
^CALL $--ncd --nrcd --qd --ret:&&ret #,%&GetIfTable%,*&Buf,*&sz,#1
SET &dwNumEntries=%&Buf?long:0%
SET &I=0
SET &Of1=%Ofb1%
LOOP #%&I%<%&dwNumEntries%,
{* CALC #&I=%&I% + 1
ENVI?long &Buf=&&dwInOctetsI:%&Of1% //DWORD
ENVI?long &Buf=&&dwOutOctetsI:(%&Of1%+24)
//^CALC #&&dwInOctetsI=%%Buf?long:%&Of1%%% //DWORD
//^CALC #&&dwOutOctetsI=%%&Buf?long:(%&Of1%+24)%% //DWORD
CALC #&dwInOctets=%&dwInOctets% + %&dwInOctetsI% //dwInOctets
CALC #&dwOutOctets=%&dwOutOctets% + %&dwOutOctetsI% //dwOutOctets
CALC #&Of1=%&Of1% + %&MIBLEN%
}
CALC &dwBandIn=(%&dwInOctets% - %&dwLastIn% ) / 1024#2 //下载速度
CALC &dwBandOut=(%&dwOutOctets% - %&dwLastOut%) / 1024#2 //上传速速
SET dwLastIn=%&dwInOctets%
SET dwLastOut=%&dwOutOctets%
ENVI @&wMsg=收到字节: %&dwLastIn% bytes%&NL%发送字节: %&dwLastOut% bytes%&NL%下行速度: %&dwBandIn% KB%&NL%上行速度: %&dwBandOut% KB
_END
EXIT
typedef struct _MIB_IFTABLE {
DWORD dwNumEntries;
MIB_IFROW table[ANY_SIZE];
} MIB_IFTABLE, *PMIB_IFTABLE;
typedef struct _MIB_IFROW {
WCHAR wszName[MAX_INTERFACE_NAME_LEN];
DWORD dwIndex;
DWORD dwType;
DWORD dwMtu;
DWORD dwSpeed;
DWORD dwPhysAddrLen;
BYTE bPhysAddr[MAXLEN_PHYSADDR];
DWORD dwAdminStatus;
DWORD dwOperStatus;
DWORD dwLastChange;
DWORD dwInOctets; //
DWORD dwInUcastPkts;
DWORD dwInNUcastPkts;
DWORD dwInDiscards;
DWORD dwInErrors;
DWORD dwInUnknownProtos;
DWORD dwOutOctets; //
DWORD dwOutUcastPkts;
DWORD dwOutNUcastPkts;
DWORD dwOutDiscards;
DWORD dwOutErrors;
DWORD dwOutQLen;
DWORD dwDescrLen;
BYTE bDescr[MAXLEN_IFDESCR];
} MIB_IFROW, *PMIB_IFROW; |