Dynamic Link Library & Function Pointers

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AdrianLP
    New Member
    • Mar 2008
    • 3

    Dynamic Link Library & Function Pointers

    Hello all. I'm writing a Push To Talk radio program. As such I have a DLL that uses SetWindowsHookE x to set a callback function. This works, and is called when keyboard events take place.

    Client programs using this DLL wish to know when a keyboard event takes place (even if said client program is not in the foreground).

    So in my DLL I store a function pointer in a shared data section), and the DLL allows the clients to pass in a function pointer to be called when a keyboard event is raised.

    If the client program has focus, the callback works as expected. If the client does not have focus, the callback method is called but never returns. I suspect this is because the client's function is in a different address space then all the DLL instances except the one it explicitly creates.

    So my question is, how do you send data from a DLL to a client which may not have focus? Is a pipe the best bet?
    Last edited by AdrianLP; Mar 3 '08, 05:12 PM. Reason: Making the title more accurate
  • AdrianLP
    New Member
    • Mar 2008
    • 3

    #2
    ...I hope this isn't off topic as it refers to DLLs. I would not find a Windows-specific programming forum on this site.

    I suspect this question is less about DLLs and more about how to share data between applications using C++ (but perhaps even that is OS-specific) :(

    Comment

    • weaknessforcats
      Recognized Expert Expert
      • Mar 2007
      • 9214

      #3
      This is covered in Windows via C/C++ by Jeffrey Richter 2008.

      The aopplications are separate processes ?? Or os one a child proecess of the other?

      Most likely, you will use a mutex.

      Comment

      • AdrianLP
        New Member
        • Mar 2008
        • 3

        #4
        Originally posted by weaknessforcats
        This is covered in Windows via C/C++ by Jeffrey Richter 2008.

        The aopplications are separate processes ?? Or os one a child proecess of the other?

        Most likely, you will use a mutex.
        There is one client, and it uses LoadLibrary to get the DLL (which installs a global keyboard hook).

        As long as the client is in focus, the DLL can call a callback function which the client provides it with. If however the client is not in focus, the callback never returns.

        The trouble is, what I understand from the MSDN, the DLL is duplicated many times (once for each running application) to handle the keyboard hooking. Only one instance has access to the callback method though.

        Comment

        • weaknessforcats
          Recognized Expert Expert
          • Mar 2007
          • 9214

          #5
          Focus may not be the issue. Are the Windows on separate threads?

          I expect they will have to be to support multi-processing.

          Comment

          Working...