moving from c++ to visual studio c++ (winpcap)

E

exman

Hi !
i have a problem related to winpcap, i'm curretly making a sniffer
aplication for my studies.
I want to accomplish this
http://www.winpcap.org/docs/man/html/group__wpcap__tut3.html
but in visual studio, the problem is related to the function

pcap_loop(adhandle, 0, packet_handler, NULL);

it has a pointer to the function packet_handler.
It works fine in console, but how do i make it work in windows forms??

a have made an form with an button which pressed should do the stuff
that the function main does in te program from the above linlk, but
should call the function from inside the class like this:

namespace sniffer {
/ /code
public ref class Form1 : public System::Windows::Forms::Form
{
....................


private: System::Void buttonStart_Click(System::Object^ sender,
System::EventArgs^ e) {
//some code

pcap_loop(adhandle, 0, packet_handler, NULL);

}//koniec obslugi przycisku start

public: void packet_handler(u_char *param, const struct pcap_pkthdr
*header, const u_char *pkt_data)
{ }

};


the function reference worked fine when i've putted it outside the
class but then i dont know how to get the data from the function to
members of the class.
 
P

peter koch

exman skrev:
Hi ! [snip]
it has a pointer to the function packet_handler.
It works fine in console, but how do i make it work in windows forms??

a have made an form with an button which pressed should do the stuff
that the function main does in te program from the above linlk, but
should call the function from inside the class like this:

namespace sniffer {
/ /code
public ref class Form1 : public System::Windows::Forms::Form
{
....................


private: System::Void buttonStart_Click(System::Object^ sender,
System::EventArgs^ e) {
[snip]
The code above is not C++, so why do you post it here? If it is C#,
post your question in a forum dedicated to that language (probably
public.microsoft........)

/Peter
 
E

exman

exman skrev:
Hi ! [snip]
it has a pointer to the function packet_handler.
It works fine in console, but how do i make it work in windows forms??
a have made an form with an button which pressed should do the stuff
that the function main does in te program from the above linlk, but
should call the function from inside the class like this:
namespace sniffer {
/ /code
public ref class Form1 : public System::Windows::Forms::Form
{
....................
private: System::Void buttonStart_Click(System::Object^ sender,
System::EventArgs^ e) {[snip]
The code above is not C++, so why do you post it here? If it is C#,
post your question in a forum dedicated to that language (probably
public.microsoft........)

/Peter

Its visual C++ not C# thats why i post it here
 
K

Kai-Uwe Bux

exman said:
exman skrev:
Hi ! [snip]
it has a pointer to the function packet_handler.
It works fine in console, but how do i make it work in windows forms??
a have made an form with an button which pressed should do the stuff
that the function main does in te program from the above linlk, but
should call the function from inside the class like this:
namespace sniffer {
/ /code
public ref class Form1 : public System::Windows::Forms::Form
{
....................
private: System::Void buttonStart_Click(System::Object^ sender,
System::EventArgs^ e) {[snip]
The code above is not C++, so why do you post it here? If it is C#,
post your question in a forum dedicated to that language (probably
public.microsoft........)

/Peter

Its visual C++ not C# thats why i post it here

It's not C++ as defined per ISO/IEC 14882. That's why it does not belong
here.


Best

Kai-Uwe Bux
 
J

Jacek Dziedzic

exman said:
exman skrev:
Hi ! [snip]
it has a pointer to the function packet_handler.
It works fine in console, but how do i make it work in windows forms??
a have made an form with an button which pressed should do the stuff
that the function main does in te program from the above linlk, but
should call the function from inside the class like this:
namespace sniffer {
/ /code
public ref class Form1 : public System::Windows::Forms::Form
{
....................
private: System::Void buttonStart_Click(System::Object^ sender,
System::EventArgs^ e) {[snip]
The code above is not C++, so why do you post it here? If it is C#,
post your question in a forum dedicated to that language (probably
public.microsoft........)

/Peter

Its visual C++ not C# thats why i post it here

This is not C++ -- that funky "^" character is a dead giveaway,
unless you do weird things with your preprocessor, like

#define ^ &

Anyway, you've got a wrong newsgroup here, try the microsoft
hierarchy.

- J.
 
E

exman

exman said:
exman skrev:
Hi !
[snip]
it has a pointer to the function packet_handler.
It works fine in console, but how do i make it work in windows forms??
a have made an form with an button which pressed should do the stuff
that the function main does in te program from the above linlk, but
should call the function from inside the class like this:
namespace sniffer {
/ /code
public ref class Form1 : public System::Windows::Forms::Form
{
....................
private: System::Void buttonStart_Click(System::Object^ sender,
System::EventArgs^ e) {[snip]
The code above is not C++, so why do you post it here? If it is C#,
post your question in a forum dedicated to that language (probably
public.microsoft........)
/Peter
Its visual C++ not C# thats why i post it here This is not C++ -- that funky "^" character is a dead giveaway,
unless you do weird things with your preprocessor, like

#define ^ &

Anyway, you've got a wrong newsgroup here, try the microsoft
hierarchy.

- J.

Ok i'll try another group
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,567
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top