//--------------------------------------------------------------------------------- #include <windows.h> #include #include <stdio.h> int main() { typedef DWORD (WINAPI *PFONCTION)(PMIB_IFTABLE , PULONG, BOOL); PMIB_IFTABLE buffer ; MIB_IFROW donnees; HINSTANCE ip_help_handle = NULL; DWORD getiftable_rc; ULONG buf_size=0; ip_help_handle = LoadLibrary("iphlpapi.dll"); if (ip_help_handle == NULL) return 1; PFONCTION get_if_table=(PFONCTION) GetProcAddress(ip_help_handle,"GetIfTable"); if (get_if_table == NULL) { FreeLibrary(ip_help_handle); return 1; } buffer = (MIB_IFTABLE*) malloc(sizeof(MIB_IFTABLE)); getiftable_rc = get_if_table (buffer, &buf_size, TRUE); buffer = (MIB_IFTABLE *) malloc (buf_size); DWORD i; //Ici pourrait etre le debut d'une boucle infinie getiftable_rc = get_if_table (buffer, &buf_size, TRUE); for (i=1;idwNumEntries;i++) { donnees=buffer->table[i]; printf("\n%s%d\t%s%d\t%s%d","Interface:",i,"Upload:",donnees.dwOutOctets,"Download:",donnees.dwInOctets); } //Ici pourrait etre la fin de la boucle infinie printf ("\n\nTaper sur ENTREE pour quitter"); getchar(); FreeLibrary(ip_help_handle); return 0; }
Compiling... test.cpp Linking... Creating library Debug/band.lib and object Debug/test.exp test.obj : error LNK2001: unresolved external symbol _GetIfTable@12 test.obj : error LNK2001: unresolved external symbol __imp___TrackMouseEvent@4 Debug/band.dll : fatal error LNK1120: 2 unresolved externals Error executing link.exe.
ULONG o_get,o_snd,get,snd,gets,snds,o_snds,o_gets,s,xyz; char titleb[1024]; PMIB_IFTABLE ifMIB; char signal[900]; #define TBAND 150 o_get o_snd snd = get = gets = snds = o_gets = o_snds = xyz = s = 0; GetIfTable(0,&s,1); ifMIB = (PMIB_IFTABLE)malloc((size_t)s); SetTimer(hwnd,TBAND, 1000, (TIMERPROC) BANDR);
VOID CALLBACK BANDR(HWND hwnd,UINT message,UINT idTimer,DWORD dwTime) { ULONG x; x=0; GetIfTable(ifMIB,&s,1);o_get get; o_snd snd; get=snd=0; while (x <= ifMIB->dwNumEntries) {get ifMIB->table[x].dwInOctets + get; snd ifMIB->table[x].dwOutOctets + snd; x++; }o_gets gets; o_snds snds; if (xyz < 4) xyz++;if (xyz 4) { gets (get - o_get); snds = (snd - o_snd); } } VOID CALLBACK BANDS(HWND hwnd,UINT message,UINT idTimer,DWORD dwTime) { char text[1024]; wsprintf(text,"%s [Band: %d dn %d up]", titleb, gets/1000, snds/1000); SetWindowText(mIRC_hwnd, text); }
DWORD download=0,download2=0,band=0; char *buffer = NULL; DWORD count; HINSTANCE ip_help_handle = NULL; DWORD getiftable_rc; ULONG buf_size; MIB_IFROW *ifr; MIB_IFTABLE *ift; DWORD ii=0,jj=0; ip_help_handle = LoadLibrary("iphlpapi.dll"); if (ip_help_handle == NULL) return 0; get_if_table = (LPGETIFTABLE) GetProcAddress(ip_help_handle, "GetIfTable"); if (get_if_table == NULL) return 0; buf_size = 0; getiftable_rc = (*get_if_table)((PMIB_IFTABLE) buffer, &buf_size, TRUE); if (getiftable_rc != ERROR_INSUFFICIENT_BUFFER) return 0; buffer = (char *) malloc(buf_size); if (buffer == NULL) return 0; memset(buffer, 0, buf_size); getiftable_rc = (*get_if_table)((PMIB_IFTABLE) buffer, &buf_size, TRUE); if (getiftable_rc != NO_ERROR) return 0;
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.