In the past, it was easy to see people use Winpcap. Today, some time has also been posted on the Internet ~~
We don't want "Hello World" anymore. If Winpcap doesn't come out, we just need a program that prints the list of available network cards on this machine. This is the most simple one.
Go to http://www.winpcap.org/install/bin/winpcap_4_0.exeand install Winpcap,
Go to the slave copy "and change the name. This is our first program, which is called test. Which of the following "udpdump. DSP and udpdump. change DSW to test. DSP "," test. DSW, and then use the notebook to open these two files. Replace "udpdump" into our "test ", in this case, the user's udpdump project becomes our test project. Use VC to open the test project. In the right pane, we can see the source file udpdump. c. Head file pcap. h. Delete the source file and add a main file to the file. CPP and fill in the following tokens:
Main. cpp:
# Include "pcap. H"
Void main (void)
...{
Pcap_if_t * alldevs;
Pcap_if_t * D;
Int I = 0;
Char errbuf [pcap_errbuf_size];
// Obtain the list
If (pcap_findalldevs (& alldevs, errbuf) =-1 )...{
Fprintf (stderr, "error in pcap_findalldevs: % s", errbuf );
Exit (1 );
}
// Outputs the list
For (D = alldevs; D = D-> next )...{
Printf ("% d. % s", ++ I, d-> name );
If (D-> description )...{
Printf ("(% s)", D-> description );
} Else ...{
// Y-no valid description
Printf ("(not described )");
}
}
If (I = 0 )...{
// Y-there is no valid interface, or it may be because there is no secure Winpcap
Printf ("interface not found! Confirm whether or not to install Winpcap. ");
Return;
}
// Release list
Pcap_freealldevs (alldevs );
}
The network card interface list of the organization, OK, operation, and current machine is displayed ~
// Note: If you are an XP sp2 workstation and cannot find any iphlpapi. Lib file during the creation, you need to install a package, big package, and
Http://www.microsoft.com/msdownload/platformsdk/sdkupdate/XPSP2FULLInstall.htm
Go to the next page ~~~