CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2011
    Posts
    0

    Angry How to call CALLBACK from inside DLL

    Hi

    I make a wraper dll ...

    So, I need to export to aplication some result...

    Well. this is code:

    xVideo.h

    #ifndef xVideoDEF

    #define xVideoDEF(f) WINAPI f

    #endif



    typedef BOOL (CALLBACK CallBackEnumerator)(char * name,GUID guid,void * user);

    /*

    name - the device name

    GUID - the device CLSID

    user - The 'user' parameter

    */



    //xVideo_Capture_xxx functions flags

    //...........................................

    #define xVideo_AudioCapture 0x10066

    #define xVideo_VideoCapture 0x10080



    int xVideoDEF(xVideo_CaptureGetDevices)(DWORD devicetype,CallBackEnumerator *callback,void* user);

    // Of course, this is only part of xVideo.h, But I only have problems with callbacks, This here is only one from

    //several simiral callbacks

    //************************************************************

    main.cpp
    #include <windows.h>
    #include <xVideo.h>
    using namespace std;
    #define export extern "C" __declspec (dllexport)

    BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ ,

    DWORD reason /* Reason this function is being called. */ ,

    LPVOID reserved /* Not used. */ )

    {

    switch (reason)

    {

    case DLL_PROCESS_ATTACH:
    break;
    case DLL_PROCESS_DETACH:

    break;
    case DLL_THREAD_ATTACH:

    break;
    case DLL_THREAD_DETACH:

    break;
    }

    /* return (double)s TRUE on success, FALSE on failure */

    return TRUE;

    }

    extern "C" {

    export double GM_xVideo_CaptureGetDevices(double devicetype){

    double result=0;

    if (devicetype==0){result=(double)(int) xVideo_CaptureGetDevices(xVideo_AudioCapture,&GetDevicesCallback,NULL); }

    if (devicetype==1){result= (double)(int)xVideo_CaptureGetDevices(xVideo_VideoCapture,&GetVideoDevicesCallback,NULL); }

    return(double)result;

    }

    }

    // This is only error related part of all main.cpp

    //************************************************************

    Please What to do??? Callbacks in this way don't work

    I was try to make *.def file, but i got only errors...

    Tnx in advance

  2. #2
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    Re: How to call CALLBACK from inside DLL

    Here's a minimal example in VS2008 of doing a callback from the dll to the exe.
    Attached Files Attached Files
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  3. #3
    Join Date
    Nov 2000
    Location
    Voronezh, Russia
    Posts
    6,620

    Re: How to call CALLBACK from inside DLL

    Please What to do??? Callbacks in this way don't work
    Please explain what doesn't work. Besides, I cannot see any callback call in your code.
    Best regards,
    Igor

Tags for this Thread

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