CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2003
    Posts
    1

    Question Address of class method

    How can I send an address of a class method,
    say class1::func()
    to a callback function (writen in C) its parameter is a pointer to function.
    THanx!

  2. #2
    Join Date
    Apr 2003
    Posts
    1,755

    Smile

    U can use static function.

    But be sure you have a way to get a psuedo this if you want to use the member variables.

    The other way I do this is to place a dummy call to the function and then get the function address by using __asm. This is the code I made

    Code:
    class myclass {
    public:
       void myproc1(DWORD x)
       {
          return;
       };
    
       int myProc2(DWORD y) {
          int myaddress;
          __asm {
             mov eax, offset MYPROC_FIN
             mov ecx, [eax - 4]
             add eax, ecx
             mov [myaddress], eax
             jmp MYPROC_FIN
             }
             myproc1(0);
       MYPROC_FIN:
              // u can now use the value of myaddress
             ....
             ....
       };
    };
    Hope this will help you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured