CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,867

    Callback functions and DLL's

    Before I embark on something stupid I just wanted to check if it's even possible....

    I have a DLL which, among other things, can open certain types of media file (JPEG, WAV, AIFF etc). If the media is opened successfully, it gets put into a user defined buffer supplied by the calling application (i.e. my program). Fortunately, I have the source code for the DLL.

    I'd like to set up the ability for the DLL to use a callback function to modify the data before it gets put into the buffer (e.g. changing the sample rate). The callback function would need to be in the main app of course, not in the DLL. Here's my question....

    Can a DLL actually call a function in the main application's executable? Obviously I'd need to supply the function's address but is such a callback feasible or am I just asking for trouble?
    "A problem well stated is a problem half solved.” - Charles F. Kettering

  2. #2
    Join Date
    Jan 2004
    Posts
    56
    Yes, it's possible. I remember in the Petzold's "Programming Windows" fifth edition there's a example that's similar to ur situation.
    Trust urself!

  3. #3
    John E is offline Elite Member Power Poster
    Join Date
    Apr 2001
    Location
    Manchester, England
    Posts
    4,867
    Blimey, you're right. It even explains how two apps can both set their own callbacks without upsetting the DLL. Thanks!
    "A problem well stated is a problem half solved.” - Charles F. Kettering

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