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
| void TDebits::RecusEnvoyes(unsigned long int& Recus, unsigned long int& Envoyes)
{
char buf[256];
unsigned int uiRecus, uiEnvoyes;
HINSTANCE Dll =LoadLibrary(L"iphlpapi.dll");
if(Dll == NULL)
{
AnsiString asLigne = "Impossible de charger la DLL iphlpapi.dll";
asLigne += "\n Le programme va se fermer";
ShowMessage(asLigne);
Close();
}
PMIB_IFTABLE buffer;
MIB_IFROW donnees;
DWORD getiftable_rc;
ULONG buf_size = 0;
typedef DWORD( *MYDLLFUNCTION)( PMIB_IFTABLE , PULONG , BOOL );
MYDLLFUNCTION getiftable;
getiftable = (MYDLLFUNCTION)GetProcAddress(Dll, "GetIfTable");
buffer = (MIB_IFTABLE*) malloc(sizeof(MIB_IFTABLE));
getiftable_rc = getiftable(buffer, &buf_size, TRUE);
free(buffer);
buffer = (MIB_IFTABLE*) malloc(buf_size);
getiftable_rc = getiftable(buffer, &buf_size, TRUE);
DWORD dwOutOctets, dwInOctets;
dwOutOctets = dwInOctets =0;
for(unsigned int i = 0; i < buffer->dwNumEntries; i++)
{
donnees = buffer->table[i];
dwOutOctets += donnees.dwOutOctets;
dwInOctets += donnees.dwInOctets;
}
uiRecus = dwInOctets;
uiEnvoyes = dwOutOctets;
Recus = uiRecus;
Envoyes = uiEnvoyes;
}
//--------------------------------------------------------------------- |