IdentifiantMot de passe
Loading...
Mot de passe oubli� ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les r�ponses en temps r�el, voter pour les messages, poser vos propres questions et recevoir la newsletter

MFC Discussion :

[icmp ping TTL]probleme de compilation avec HANDLE


Sujet :

MFC

  1. #1
    Membre averti

    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    48
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 48
    Par d�faut [icmp ping TTL]probleme de compilation avec HANDLE
    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 !!!

  2. #2
    R�dacteur
    Avatar de nico-pyright(c)
    Profil pro
    Inscrit en
    Octobre 2003
    Messages
    6 414
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2003
    Messages : 6 414
    Par d�faut
    pas de probleme de compil chez moi, tu es en quel mode de compilation ? unicode ? strict ?

  3. #3
    R�dacteur
    Avatar de farscape
    Homme Profil pro
    D�veloppeur informatique
    Inscrit en
    Novembre 2003
    Messages
    9 055
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes C�te d'Azur)

    Informations professionnelles :
    Activit� : D�veloppeur informatique
    Secteur : High Tech - �diteur de logiciels

    Informations forums :
    Inscription : Novembre 2003
    Messages : 9 055
    Par d�faut
    salut,
    essaye de rajouter windef.h apres windows.h

  4. #4
    Membre averti

    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    48
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 48
    Par d�faut
    Citation Envoy� par nico-pyright(c)
    pas de probleme de compil chez moi, tu es en quel mode de compilation ? unicode ? strict ?
    euh ... et comment je peux savoir ???

  5. #5
    Membre averti

    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    48
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 48
    Par d�faut
    Citation Envoy� par farscape
    salut,
    essaye de rajouter windef.h apres windows.h
    j ai teste et rien toujours les memes erreurs avec HANDLE
    a mon avis ca doit etre un probleme de config de visual c++
    si nico-pyright na pas d erreur lors de la compilation ca doit etre uniquement un rpobleme de config

  6. #6
    R�dacteur
    Avatar de nico-pyright(c)
    Profil pro
    Inscrit en
    Octobre 2003
    Messages
    6 414
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Octobre 2003
    Messages : 6 414
    Par d�faut
    tu as fait un nouveau projet console classique ? sans toucher aux settings ?

  7. #7
    Membre averti

    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    48
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 48
    Par d�faut
    oui j ai fait un new project win32 console application
    j ai juste modifier les librairie a linker c est tout

  8. #8
    R�dacteur
    Avatar de Laurent Gomila
    Profil pro
    D�veloppeur informatique
    Inscrit en
    Avril 2003
    Messages
    10 651
    D�tails du profil
    Informations personnelles :
    �ge : 41
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activit� : D�veloppeur informatique

    Informations forums :
    Inscription : Avril 2003
    Messages : 10 651
    Par d�faut
    Tu compiles en C, tu n'as donc pas le droit de d�clarer une variable apr�s d'autres instructions.

  9. #9
    Membre averti

    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    48
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 48
    Par d�faut
    Citation Envoy� par Loulou24
    Tu compiles en C, tu n'as donc pas le droit de d�clarer une variable apr�s d'autres instructions.
    ok thks c etait tout con
    j halucine
    ca se voit que j ai plus l habitude de developper en C
    depuis que je programme pratiquement que en java j oublie la base du developpement en C
    merci bcp

  10. #10
    R�dacteur
    Avatar de farscape
    Homme Profil pro
    D�veloppeur informatique
    Inscrit en
    Novembre 2003
    Messages
    9 055
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes C�te d'Azur)

    Informations professionnelles :
    Activit� : D�veloppeur informatique
    Secteur : High Tech - �diteur de logiciels

    Informations forums :
    Inscription : Novembre 2003
    Messages : 9 055
    Par d�faut
    Citation Envoy� par Loulou24
    Tu compiles en C, tu n'as donc pas le droit de d�clarer une variable apr�s d'autres instructions.
    bien vu ! ,j'avais pas fait gaffe a ce d�tail

  11. #11
    R�dacteur
    Avatar de Laurent Gomila
    Profil pro
    D�veloppeur informatique
    Inscrit en
    Avril 2003
    Messages
    10 651
    D�tails du profil
    Informations personnelles :
    �ge : 41
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activit� : D�veloppeur informatique

    Informations forums :
    Inscription : Avril 2003
    Messages : 10 651
    Par d�faut
    Par contre tu n'aurais pas d� �diter ton premier message, si d'autres personnes passent par l� elles vont se poser des questions.

    Et pense aussi au tag [R�solu]

  12. #12
    Membre averti

    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    48
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 48
    Par d�faut
    sauf que la autre probleme
    la c est avec le inet_addr
    j avais oublie de mettre la librairie, le dll et l entete :
    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
    48
    49
     
    #include <windows.h>
    #include <stdio.h>
    #include <Ipexport.h> 
    #include <Icmpapi.h>
    #include <Winsock2.h>
     
     
     
     
    int main(){ 
     
       HMODULE hICMP, hICMP2;
     
       // Declare and initialize variables 
       char *SendData = "Data Buffer"; 
       LPVOID ReplyBuffer; 
       DWORD dwRetVal;
       HANDLE hIcmpFile;
     
       hICMP = LoadLibrary("Iphlpapi.dll");
       hICMP2 = LoadLibrary("Ws2_32.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; 
    }
    sauf que la j ai plein de probleme d interference entre winsock.h et winsock2.h
    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
    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
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
     
    --------------------Configuration: test - Win32 Debug--------------------
    Compiling...
    test.c
    c:\program files\microsoft platform sdk\include\winsock2.h(112) : error C2011: 'fd_set' : 'struct' type redefinition
    c:\program files\microsoft platform sdk\include\winsock2.h(147) : warning C4005: 'FD_SET' : macro redefinition
            c:\program files\microsoft platform sdk\include\winsock.h(88) : see previous definition of 'FD_SET'
    c:\program files\microsoft platform sdk\include\winsock2.h(156) : error C2011: 'timeval' : 'struct' type redefinition
    c:\program files\microsoft platform sdk\include\winsock2.h(212) : error C2011: 'hostent' : 'struct' type redefinition
    c:\program files\microsoft platform sdk\include\winsock2.h(225) : error C2011: 'netent' : 'struct' type redefinition
    c:\program files\microsoft platform sdk\include\winsock2.h(232) : error C2011: 'servent' : 'struct' type redefinition
    c:\program files\microsoft platform sdk\include\winsock2.h(244) : error C2011: 'protoent' : 'struct' type redefinition
    c:\program files\microsoft platform sdk\include\winsock2.h(400) : error C2011: 'sockaddr_in' : 'struct' type redefinition
    c:\program files\microsoft platform sdk\include\winsock2.h(410) : error C2011: 'WSAData' : 'struct' type redefinition
    c:\program files\microsoft platform sdk\include\winsock2.h(470) : warning C4005: 'SO_DONTLINGER' : macro redefinition
            c:\program files\microsoft platform sdk\include\winsock.h(411) : see previous definition of 'SO_DONTLINGER'
    c:\program files\microsoft platform sdk\include\winsock2.h(527) : warning C4005: 'AF_IPX' : macro redefinition
            c:\program files\microsoft platform sdk\include\winsock.h(469) : see previous definition of 'AF_IPX'
    c:\program files\microsoft platform sdk\include\winsock2.h(555) : warning C4005: 'AF_MAX' : macro redefinition
            c:\program files\microsoft platform sdk\include\winsock.h(488) : see previous definition of 'AF_MAX'
    c:\program files\microsoft platform sdk\include\winsock2.h(561) : error C2011: 'sockaddr' : 'struct' type redefinition
    c:\program files\microsoft platform sdk\include\winsock2.h(601) : error C2011: 'sockproto' : 'struct' type redefinition
    c:\program files\microsoft platform sdk\include\winsock2.h(640) : error C2011: 'linger' : 'struct' type redefinition
    c:\program files\microsoft platform sdk\include\winsock2.h(653) : warning C4005: 'SOMAXCONN' : macro redefinition
            c:\program files\microsoft platform sdk\include\winsock.h(553) : see previous definition of 'SOMAXCONN'
    c:\program files\microsoft platform sdk\include\winsock2.h(679) : warning C4005: 'FD_READ' : macro redefinition
            c:\program files\microsoft platform sdk\include\winsock.h(571) : see previous definition of 'FD_READ'
    c:\program files\microsoft platform sdk\include\winsock2.h(682) : warning C4005: 'FD_WRITE' : macro redefinition
            c:\program files\microsoft platform sdk\include\winsock.h(572) : see previous definition of 'FD_WRITE'
    c:\program files\microsoft platform sdk\include\winsock2.h(685) : warning C4005: 'FD_OOB' : macro redefinition
            c:\program files\microsoft platform sdk\include\winsock.h(573) : see previous definition of 'FD_OOB'
    c:\program files\microsoft platform sdk\include\winsock2.h(688) : warning C4005: 'FD_ACCEPT' : macro redefinition
            c:\program files\microsoft platform sdk\include\winsock.h(574) : see previous definition of 'FD_ACCEPT'
    c:\program files\microsoft platform sdk\include\winsock2.h(691) : warning C4005: 'FD_CONNECT' : macro redefinition
            c:\program files\microsoft platform sdk\include\winsock.h(575) : see previous definition of 'FD_CONNECT'
    c:\program files\microsoft platform sdk\include\winsock2.h(694) : warning C4005: 'FD_CLOSE' : macro redefinition
            c:\program files\microsoft platform sdk\include\winsock.h(576) : see previous definition of 'FD_CLOSE'
    c:\program files\microsoft platform sdk\include\winsock2.h(1626) : error C2375: 'accept' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(744) : see declaration of 'accept'
    c:\program files\microsoft platform sdk\include\winsock2.h(1647) : error C2375: 'bind' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(749) : see declaration of 'bind'
    c:\program files\microsoft platform sdk\include\winsock2.h(1666) : error C2375: 'closesocket' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(754) : see declaration of 'closesocket'
    c:\program files\microsoft platform sdk\include\winsock2.h(1685) : error C2375: 'connect' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(756) : see declaration of 'connect'
    c:\program files\microsoft platform sdk\include\winsock2.h(1706) : error C2375: 'ioctlsocket' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(761) : see declaration of 'ioctlsocket'
    c:\program files\microsoft platform sdk\include\winsock2.h(1727) : error C2375: 'getpeername' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(766) : see declaration of 'getpeername'
    c:\program files\microsoft platform sdk\include\winsock2.h(1748) : error C2375: 'getsockname' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(771) : see declaration of 'getsockname'
    c:\program files\microsoft platform sdk\include\winsock2.h(1771) : error C2375: 'getsockopt' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(776) : see declaration of 'getsockopt'
    c:\program files\microsoft platform sdk\include\winsock2.h(1792) : error C2375: 'htonl' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(783) : see declaration of 'htonl'
    c:\program files\microsoft platform sdk\include\winsock2.h(1809) : error C2375: 'htons' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(785) : see declaration of 'htons'
    c:\program files\microsoft platform sdk\include\winsock2.h(1826) : error C2375: 'inet_addr' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(787) : see declaration of 'inet_addr'
    c:\program files\microsoft platform sdk\include\winsock2.h(1843) : error C2375: 'inet_ntoa' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(789) : see declaration of 'inet_ntoa'
    c:\program files\microsoft platform sdk\include\winsock2.h(1861) : error C2375: 'listen' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(791) : see declaration of 'listen'
    c:\program files\microsoft platform sdk\include\winsock2.h(1879) : error C2375: 'ntohl' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(795) : see declaration of 'ntohl'
    c:\program files\microsoft platform sdk\include\winsock2.h(1896) : error C2375: 'ntohs' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(797) : see declaration of 'ntohs'
    c:\program files\microsoft platform sdk\include\winsock2.h(1916) : error C2375: 'recv' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(799) : see declaration of 'recv'
    c:\program files\microsoft platform sdk\include\winsock2.h(1941) : error C2375: 'recvfrom' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(805) : see declaration of 'recvfrom'
    c:\program files\microsoft platform sdk\include\winsock2.h(1967) : error C2375: 'select' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(813) : see declaration of 'select'
    c:\program files\microsoft platform sdk\include\winsock2.h(1991) : error C2375: 'send' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(820) : see declaration of 'send'
    c:\program files\microsoft platform sdk\include\winsock2.h(2016) : error C2375: 'sendto' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(826) : see declaration of 'sendto'
    c:\program files\microsoft platform sdk\include\winsock2.h(2042) : error C2375: 'setsockopt' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(834) : see declaration of 'setsockopt'
    c:\program files\microsoft platform sdk\include\winsock2.h(2064) : error C2375: 'shutdown' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(841) : see declaration of 'shutdown'
    c:\program files\microsoft platform sdk\include\winsock2.h(2084) : error C2375: 'socket' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(845) : see declaration of 'socket'
    c:\program files\microsoft platform sdk\include\winsock2.h(2107) : error C2375: 'gethostbyaddr' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(852) : see declaration of 'gethostbyaddr'
    c:\program files\microsoft platform sdk\include\winsock2.h(2126) : error C2375: 'gethostbyname' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(857) : see declaration of 'gethostbyname'
    c:\program files\microsoft platform sdk\include\winsock2.h(2144) : error C2375: 'gethostname' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(859) : see declaration of 'gethostname'
    c:\program files\microsoft platform sdk\include\winsock2.h(2163) : error C2375: 'getservbyport' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(863) : see declaration of 'getservbyport'
    c:\program files\microsoft platform sdk\include\winsock2.h(2182) : error C2375: 'getservbyname' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(867) : see declaration of 'getservbyname'
    c:\program files\microsoft platform sdk\include\winsock2.h(2200) : error C2375: 'getprotobynumber' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(871) : see declaration of 'getprotobynumber'
    c:\program files\microsoft platform sdk\include\winsock2.h(2217) : error C2375: 'getprotobyname' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(873) : see declaration of 'getprotobyname'
    c:\program files\microsoft platform sdk\include\winsock2.h(2237) : error C2375: 'WSAStartup' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(877) : see declaration of 'WSAStartup'
    c:\program files\microsoft platform sdk\include\winsock2.h(2255) : error C2375: 'WSACleanup' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(881) : see declaration of 'WSACleanup'
    c:\program files\microsoft platform sdk\include\winsock2.h(2272) : error C2375: 'WSASetLastError' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(883) : see declaration of 'WSASetLastError'
    c:\program files\microsoft platform sdk\include\winsock2.h(2289) : error C2375: 'WSAGetLastError' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(885) : see declaration of 'WSAGetLastError'
    c:\program files\microsoft platform sdk\include\winsock2.h(2306) : error C2375: 'WSAIsBlocking' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(887) : see declaration of 'WSAIsBlocking'
    c:\program files\microsoft platform sdk\include\winsock2.h(2323) : error C2375: 'WSAUnhookBlockingHook' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(889) : see declaration of 'WSAUnhookBlockingHook'
    c:\program files\microsoft platform sdk\include\winsock2.h(2340) : error C2375: 'WSASetBlockingHook' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(891) : see declaration of 'WSASetBlockingHook'
    c:\program files\microsoft platform sdk\include\winsock2.h(2357) : error C2375: 'WSACancelBlockingCall' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(893) : see declaration of 'WSACancelBlockingCall'
    c:\program files\microsoft platform sdk\include\winsock2.h(2379) : error C2375: 'WSAAsyncGetServByName' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(895) : see declaration of 'WSAAsyncGetServByName'
    c:\program files\microsoft platform sdk\include\winsock2.h(2406) : error C2375: 'WSAAsyncGetServByPort' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(903) : see declaration of 'WSAAsyncGetServByPort'
    c:\program files\microsoft platform sdk\include\winsock2.h(2432) : error C2375: 'WSAAsyncGetProtoByName' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(911) : see declaration of 'WSAAsyncGetProtoByName'
    c:\program files\microsoft platform sdk\include\winsock2.h(2457) : error C2375: 'WSAAsyncGetProtoByNumber' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(918) : see declaration of 'WSAAsyncGetProtoByNumber'
    c:\program files\microsoft platform sdk\include\winsock2.h(2482) : error C2375: 'WSAAsyncGetHostByName' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(925) : see declaration of 'WSAAsyncGetHostByName'
    c:\program files\microsoft platform sdk\include\winsock2.h(2509) : error C2375: 'WSAAsyncGetHostByAddr' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(932) : see declaration of 'WSAAsyncGetHostByAddr'
    c:\program files\microsoft platform sdk\include\winsock2.h(2532) : error C2375: 'WSACancelAsyncRequest' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(941) : see declaration of 'WSACancelAsyncRequest'
    c:\program files\microsoft platform sdk\include\winsock2.h(2552) : error C2375: 'WSAAsyncSelect' : redefinition; different linkage
            c:\program files\microsoft platform sdk\include\winsock.h(943) : see declaration of 'WSAAsyncSelect'
    Error executing cl.exe.
     
    test.obj - 57 error(s), 11 warning(s)
    c est qu en meme bizarre !!!

  13. #13
    R�dacteur
    Avatar de Laurent Gomila
    Profil pro
    D�veloppeur informatique
    Inscrit en
    Avril 2003
    Messages
    10 651
    D�tails du profil
    Informations personnelles :
    �ge : 41
    Localisation : France, Moselle (Lorraine)

    Informations professionnelles :
    Activit� : D�veloppeur informatique

    Informations forums :
    Inscription : Avril 2003
    Messages : 10 651
    Par d�faut
    Il faut inclure winsock2.h avant windows.h

  14. #14
    Membre averti

    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    48
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 48
    Par d�faut
    oky thks !
    mais comment peut on savoir qu il faut mettre tel entete avant une autre ?
    faut juste tatonner ?!

  15. #15
    R�dacteur
    Avatar de farscape
    Homme Profil pro
    D�veloppeur informatique
    Inscrit en
    Novembre 2003
    Messages
    9 055
    D�tails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Alpes Maritimes (Provence Alpes C�te d'Azur)

    Informations professionnelles :
    Activit� : D�veloppeur informatique
    Secteur : High Tech - �diteur de logiciels

    Informations forums :
    Inscription : Novembre 2003
    Messages : 9 055
    Par d�faut
    non il suffit de prendre une des fonctions utilis�es et de regarder la doc MSDN:
    exemple sockaddr:
    Citation Envoy� par MSDN
    Requirements
    Windows NT/2000/XP: Included in Windows NT 3.1 and later.
    Windows 95/98/Me: Included in Windows 95 and later.
    Header: Declared in Winsock2.h.
    suffit juste de lire la doc.


  16. #16
    Membre averti

    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    48
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 48
    Par d�faut
    ca d'accord mais pourquoi il faut mettre winsock2.h avant windows.h ?

    autre questiopn now que ca compile bien je veux recuperer le TTL dans la structure ReplyBuffer (ICMP_ECHO_REPLY)

    donc d apres la msdn, pour recuperer l option TTl il faut faire :
    ???

  17. #17
    Membre averti

    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    48
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 48
    Par d�faut
    un peu + de precision
    ReplyBuffer est un pointeur sur une structure ICMP_ECHO_REPLY
    donc si je fais comme ci dessous ca devrait marcher :
    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
    4
     
    struct icmp_echo_reply rep;
    rep.Data=ReplyBuffer;
    printf("TTl : %s",Rep.Options.Ttl);
    et j ai un warning

    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
    4
     
    test.c(51) : warning C4700: local variable 'rep' used without having been initialized
     
    test.obj - 0 error(s), 1 warning(s)
    le code :
    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
    48
    49
    50
    51
    52
    53
    #include <Winsock2.h>
    #include <windows.h>
    #include <stdio.h>
    #include <Ipexport.h> 
    #include <Icmpapi.h>
     
     
     
     
     
     
    int main(){ 
     
       HMODULE hICMP, hICMP2;
     
       // Declare and initialize variables 
       char *SendData = "Data Buffer"; 
       LPVOID ReplyBuffer; 
       DWORD dwRetVal;
       HANDLE hIcmpFile;
       struct icmp_echo_reply rep;
     
       hICMP = LoadLibrary("Iphlpapi.dll");
       hICMP2 = LoadLibrary("Ws2_32.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("164.131.87.2"), 
         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);
       rep.Data=ReplyBuffer;
       printf("TTl : %s",rep.Options.Ttl);
       return 0;
    }

  18. #18
    Membre averti

    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    48
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 48
    Par d�faut
    bon j arrive a recup�rer le temps du ping mais le TTl il m a l air bizzarre
    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
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
     
    #include <Winsock2.h>
    #include <windows.h>
    #include <stdio.h>
    #include <Ipexport.h> 
    #include <Icmpapi.h>
     
     
     
     
     
     
    int main(){ 
     
       HMODULE hICMP, hICMP2;
     
       // Declare and initialize variables 
       char *SendData = "Data Buffer"; 
       LPVOID ReplyBuffer; 
       DWORD dwRetVal;
       HANDLE hIcmpFile;
       PICMP_ECHO_REPLY *rep;
       PIP_OPTION_INFORMATION *info;
     
       hICMP = LoadLibrary("Iphlpapi.dll");
       hICMP2 = LoadLibrary("Ws2_32.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("127.0.0.1"), 
         SendData, sizeof(SendData), 
         NULL, ReplyBuffer, 
         sizeof(ReplyBuffer) + sizeof(ICMP_ECHO_REPLY), 
         1000)) != 0) { 
         printf("\tReceived %ld messages.\n", dwRetVal); 
         //printf("\tMessage: %s\n", ReplyBuffer); 
    	 IcmpCloseHandle(hIcmpFile);
    	 rep=(PICMP_ECHO_REPLY *)ReplyBuffer;
    	 printf("time : %u\n",rep[2]);
    	 info=(PIP_OPTION_INFORMATION *)rep[6];
    	 printf("TTl : %u\n",(u_long)info[0]);
       } 
       else { 
         printf("\tCall to IcmpSendEcho() failed.\n"); 
         printf("\tError: %ld\n", GetLastError()); 
       } 
     
     
       return 0;
    }
    et le resultat est
    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
    4
    5
     
            File created.
            Received 1 messages.
    time : 0
    TTl : 1635017028
    alors que normalement il doit etre de 127 ms
    donc un petit probleme
    j essaye de voir d'ou ca vient mais si vous savez faites moi signe

  19. #19
    Membre averti

    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    48
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 48
    Par d�faut
    le probleme peut venir de la :
    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
    3
    4
    5
    6
    7
    8
     
    typedef struct ip_option_information {  
      UCHAR Ttl;  
      UCHAR Tos;  
      UCHAR Flags;  
      UCHAR OptionsSize;  
      PUCHAR OptionsData;
    } IP_OPTION_INFORMATION, *PIP_OPTION_INFORMATION;
    le parametre Ttl est de type UCHAR alors que moi je le prend pour un ULONG
    comment faire pour passer de UCHAR a ULONG voila ma question ?
    parce que si je mets %c a la place de %u
    Code : S�lectionner tout - Visualiser dans une fen�tre � part
    1
    2
     
    printf("TTl : %c\n",info[0]);
    j ai comme resultat :
    donc ca na aps l air bon

  20. #20
    Membre averti

    Profil pro
    Inscrit en
    Janvier 2005
    Messages
    48
    D�tails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Janvier 2005
    Messages : 48
    Par d�faut
    c bon j ai reussi ah obtenir les informations temps du ping et TTl
    mon code qui ne gere pas encore les erreurs est :
    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
    48
    49
    50
     
    #include <Winsock2.h>
    #include <windows.h>
    #include <stdio.h>
    #include <Ipexport.h> 
    #include <Icmpapi.h>
     
     
    int main(){ 
     
       HMODULE hICMP, hICMP2;
     
       // Declare and initialize variables 
       char *SendData = "Data Buffer"; 
       LPVOID ReplyBuffer; 
       DWORD dwRetVal;
       HANDLE hIcmpFile;
       ICMP_ECHO_REPLY* rep;
     
       hICMP = LoadLibrary("Iphlpapi.dll");
       hICMP2 = LoadLibrary("Ws2_32.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("127.0.0.1"), 
         SendData, sizeof(SendData), 
         NULL, ReplyBuffer, 
         sizeof(ReplyBuffer) + sizeof(ICMP_ECHO_REPLY), 
         1000)) != 0) { 
         printf("\tReceived %ld messages.\n", dwRetVal); 
         //printf("\tMessage: %s\n", ReplyBuffer); 
    	 IcmpCloseHandle(hIcmpFile);
    	 rep=(ICMP_ECHO_REPLY *)ReplyBuffer;
    	 printf("time : %u\n",rep->RoundTripTime);
    	 printf("TTl : %d\n",rep->Options.Ttl);
       } 
       else { 
         printf("\tCall to IcmpSendEcho() failed.\n"); 
         printf("\tError: %ld\n", GetLastError());
       } 
       return 0;
    }
    donc ce code permet d obtenir les infos ICMP ping et TTL
    merci pour les infos les gars
    j ai quand m�me reussi a trouver tout seul vers la fin

+ R�pondre � la discussion
Cette discussion est r�solue.

Discussions similaires

  1. probleme de compilation avec wx-devcpp
    Par anarpunk dans le forum Autres �diteurs
    R�ponses: 7
    Dernier message: 27/12/2005, 11h13
  2. John :: Help!! Probleme de compilation avec SDL_gfx
    Par Raggajohnjohn dans le forum Autres �diteurs
    R�ponses: 5
    Dernier message: 29/10/2005, 15h46
  3. Problème de compilation avec gcc
    Par Niktou dans le forum Linux
    R�ponses: 9
    Dernier message: 27/09/2005, 15h18
  4. probleme de compilation avec boost
    Par doof dans le forum Biblioth�ques
    R�ponses: 7
    Dernier message: 07/06/2005, 21h38
  5. Problemes de compilation avec g++ sous linux
    Par Selimmel dans le forum Autres �diteurs
    R�ponses: 3
    Dernier message: 19/09/2003, 13h43

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo