I have the following winPcap problem using windows forms in C++ with the winPcap functions (after pushing a button in the windowsform).
Introduction/background:
-------------------
I've build an extensive GUI application for working with some hardware which are connected and distributing messages and information by ethernet packages.
The GUI is build in Visual Studio 2010 (and also working with 2012) and using C++ and some C code. And should send or receive some specific message.
I thought to get this adressed I should use winPcap (and installed the full package and got an example working in a general console programm, so it's woking fine!)
When I open the GUI program (XXX.H) and assign some code to a specific button (in this case, just initialization or check how many devices are attached) I wanted to use the C code of the same example I got running in the console program.
HERES THE PROBLEM
-------------------
I can not define the library in the XXXX.H and when I iclude it in the main C++/C programfile I can not adress the libraries in the GUI.H file.
HOW DO I ADRESS the winPcap variables and functions in the XXX.H file?
As it's not a class I can not define namespace (it seems) or open the library in the XXX.h, so I wonder how I can access the library and it's functions and variables in the program.
First of all: thanks to the replies, and with your help and some other friends I solved the problems.
For those who are working with Windows Forms AND the WinPcap library it's important to understand the following:
The WinPcap library can NOT be used easily as including some of the functions will not be compiled without warnings and errors and the code will not run. Main problem here is the usage of Managed Code VS Unmanaged code.
To still work with your code there are several solutions:
After correctly set all details in the LINKER and other settings for the WinPcap (find this at winPcap.org or check some video's or examples on this. This will solve the LNKerrors etc..
- Set the setting for the Common Language Runtime Support and change it from /clr:pure to /clr
-> Make sure that the library is included in your code file!!
- Use a wrapper around the code in a seperate file (or try using the sharpPcap library as this already wrapped, but I did not try to use this. Can also be used as an example for your own codewrap).