I am trying to monitor my monthly network usage. Because the default Windows 10 Data Usage page doesn't work, I took the opportunity to learn C++, as I am familiar with languages like Python and PHP.
Upon hours of Google Searching, I came to the conclusion that WinPcap is the module I should use. I downloaded it from here: https://www.winpcap.org/devel.htm
I extracted the .zip into my C++ console application folder. So my application is in C:\Visual Studio\ProjectName123\
, and I extracted WpdPack/
into there.
I am trying to use their example code:
#include "pch.h"
#include "WpdPack\Include\pcap\pcap.h"
main()
{
pcap_if_t *alldevs;
pcap_if_t *d;
int i = 0;
char errbuf[PCAP_ERRBUF_SIZE];
/* Retrieve the device list from the local machine */
if (pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL /* auth is not needed */, &alldevs, errbuf) == -1)
{
fprintf(stderr, "Error in pcap_findalldevs_ex: %s\n", errbuf);
exit(1);
}
/* Print the list */
for (d = alldevs; d != NULL; d = d->next)
{
printf("%d. %s", ++i, d->name);
if (d->description)
printf(" (%s)\n", d->description);
else
printf(" (No description available)\n");
}
if (i == 0)
{
printf("\nNo interfaces found! Make sure WinPcap is installed.\n");
return;
}
/* We don't need any more the device list. Free it */
pcap_freealldevs(alldevs);
}
I get several errors, starting with: identifier "PCAP_SRC_IF_STRING" is undefined
Extremely frustrating following an example to the T, and it not running correctly. Extremely frustrated with C++.
Help would be appreciated, specifically explaining why my code, which follows this example perfectly, doesn't run.