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

Discussion in 'C++' started by exman, Dec 11, 2006.

  1. exman

    exman Guest

    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.
     
    exman, Dec 11, 2006
    #1
    1. Advertising

  2. exman

    peter koch Guest

    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
     
    peter koch, Dec 11, 2006
    #2
    1. Advertising

  3. exman

    exman Guest

    On 11 Gru, 13:17, "peter koch" <> wrote:
    > 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
     
    exman, Dec 11, 2006
    #3
  4. exman

    Kai-Uwe Bux Guest

    exman wrote:

    >
    >
    > On 11 Gru, 13:17, "peter koch" <> wrote:
    >> 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
     
    Kai-Uwe Bux, Dec 11, 2006
    #4
  5. exman wrote:
    >
    > On 11 Gru, 13:17, "peter koch" <> wrote:
    >> 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.
     
    Jacek Dziedzic, Dec 11, 2006
    #5
  6. exman

    exman Guest

    On 11 Gru, 13:46, Jacek Dziedzic <>
    wrote:
    > exman wrote:
    >
    > > On 11 Gru, 13:17, "peter koch" <> wrote:
    > >> 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
     
    exman, Dec 11, 2006
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. wh
    Replies:
    2
    Views:
    531
    Cowboy \(Gregory A. Beamer\)
    Jan 16, 2004
  2. Thirumalai
    Replies:
    0
    Views:
    674
    Thirumalai
    May 22, 2006
  3. rockdale
    Replies:
    1
    Views:
    620
    Juan T. Llibre
    Aug 23, 2006
  4. xman
    Replies:
    0
    Views:
    513
  5. xman
    Replies:
    1
    Views:
    611
    Victor Bazarov
    Aug 17, 2005
Loading...

Share This Page