Shared Variable in a DLL
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 8 of 8

Thread: Shared Variable in a DLL

  1. #1
    Join Date
    Apr 2004
    Posts
    4

    Shared Variable in a DLL

    I have written WIN32 ( Non MFC ) dll using VC++ 6.0 visual studio. The
    exported functions are called by another application which returns
    shared variable defined in pragma. This works correctly on my PC.
    I have copied the EXE and dll on another PC. The application runs
    without any errors but the values returned from the functions are not
    correct. Mostly the intialised values are returned (i.e. if boolean is
    initialised to TRUE , the it is only returned , if int is intialised
    to 0 then 0 is returned)
    I put a messagebox to display the values in dll function. It displays
    correct values in my PC but 'initialised values' in other PC.
    Both PCs have same operating system as Win2K.
    Do I have to do something else so that functions behave correcly on
    all the machine ?
    rgds
    Rajesh

  2. #2
    Join Date
    May 1999
    Location
    DELAWARE, USA
    Posts
    9,915
    Very difficult to resolve without going over the code in the project.
    Are you running the same builds on both computers (debug, release)? Are builds for an exe and dll modules the same?
    How did you set linker options?
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  3. #3
    Join Date
    Apr 2004
    Posts
    4
    Thanks JohnCz,
    I have complied release of the dll. The dll and exe are different.
    In fact exe is built in SQLWINDOWS.
    Actually multiple applications shall be hooked .
    function getMyTime and getMyFlag are used to send the shared variable to third application

    Thanks and rgds
    Rajesh
    Attached Files Attached Files

  4. #4
    Join Date
    May 1999
    Location
    DELAWARE, USA
    Posts
    9,915
    In files you have attached:

    Where is definition of msghook123? I can see only prototype.

    Furthermore, if you are trying to create global hook, filtering messages for all threads, thread ID must be set to NULL.

    If you are trying to filter mouse message I think you would be better off using global mouse hook. For Windows NT family you can use WH_MOUSE_LL hook.

    By the way attaching whole project would be better than just files.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  5. #5
    Join Date
    Apr 2004
    Posts
    4
    Thanks JohnCz,
    I have attached the project.
    Thanks and rgds
    rajesh
    Attached Files Attached Files

  6. #6
    Join Date
    May 1999
    Location
    DELAWARE, USA
    Posts
    9,915
    You have made several mistakes; find all doing comparison. I have also added dialog to demonstrate how process hook messages.

    Most significant export, and setting thread ID.

    Hook should notify application about events by posting (important!) messages should application act on certain messages. DLL should perform needed filtering itself.

    I have defined couple of messages for that reason. You could use RegisterWindowMessage but since we know what window messages are sent I do not think that would be necessary.
    Attached Files Attached Files
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  7. #7
    Join Date
    Apr 2004
    Posts
    4
    Thanks JohnCz.
    I think I can build on ur advise.
    Actually I have 20 exes to hook, and 21st exe to send the message to depending on the first 20 exes.
    thanks and rgds
    Rajesh

  8. #8
    Join Date
    May 1999
    Location
    DELAWARE, USA
    Posts
    9,915
    You are wery welcome.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center