mon code a l'air correcte vu que c est du copier coller de la msdn pour icmpsendecho et icmpcreatefile
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
//modifie apres probleme d instruction
#include <windows.h>
#include <stdio.h> 
#include <Ipexport.h> 
#include <Icmpapi.h> 
 
 
 
int main(){ 
 
   HMODULE hICMP;
 
   // Declare and initialize variables 
   char *SendData = "Data Buffer"; 
   LPVOID ReplyBuffer; 
   DWORD dwRetVal;
   HANDLE hIcmpFile;
 
   hICMP = LoadLibrary("Iphlpapi.dll");
 
   ReplyBuffer = (VOID*) malloc(sizeof(ICMP_ECHO_REPLY) + sizeof(SendData)); 
 
   hIcmpFile = IcmpCreateFile(); 
   if (hIcmpFile == INVALID_HANDLE_VALUE) 
     printf("\tUnable to open file.\n"); 
   else 
     printf("\tFile created.\n"); 
 
 
   if ((dwRetVal = IcmpSendEcho(hIcmpFile, 
     inet_addr("123.456.789.0"), 
     SendData, sizeof(SendData), 
     NULL, ReplyBuffer, 
     sizeof(ReplyBuffer) + sizeof(ICMP_ECHO_REPLY), 
     1000)) != 0) { 
     printf("\tReceived %ld messages.\n", dwRetVal); 
     printf("\tMessage: %s\n", ReplyBuffer); 
   } 
   else { 
     printf("\tCall to IcmpSendEcho() failed.\n"); 
     printf("\tError: %ld\n", GetLastError()); 
   } 
 
   IcmpCloseHandle(hIcmpFile); 
   return 0; 
}
et lorsque je compile erreur de type avec HANDLE :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
 
--------------------Configuration: test - Win32 Debug--------------------
Compiling...
test.c
C:\VCARRAUD\Mes Documents\test\test.c(19) : error C2275: 'HANDLE' : illegal use of this type as an expression
        c:\program files\microsoft platform sdk\include\winnt.h(334) : see declaration of 'HANDLE'
C:\VCARRAUD\Mes Documents\test\test.c(19) : error C2146: syntax error : missing ';' before identifier 'hIcmpFile'
C:\VCARRAUD\Mes Documents\test\test.c(19) : error C2065: 'hIcmpFile' : undeclared identifier
C:\VCARRAUD\Mes Documents\test\test.c(19) : warning C4047: '=' : 'int ' differs in levels of indirection from 'void *'
C:\VCARRAUD\Mes Documents\test\test.c(20) : warning C4047: '==' : 'int ' differs in levels of indirection from 'void *'
C:\VCARRAUD\Mes Documents\test\test.c(26) : warning C4022: 'IcmpSendEcho' : pointer mismatch for actual parameter 1
C:\VCARRAUD\Mes Documents\test\test.c(40) : warning C4022: 'IcmpCloseHandle' : pointer mismatch for actual parameter 1
Error executing cl.exe.
 
test.obj - 3 error(s), 4 warning(s)
j ai bien linke la librairie Iphlpapi.lib
help me please !!!