Sharing a global variable in a DLL 
Author Message
 Sharing a global variable in a DLL

In my DLL there is a global variable and I've defined it like this:

#pragma data_seg(".SHARED")
RECT g_rcBox = { 0, 0, 0, 0 };
#pragma data_seg()

This is what is in my .DEF file:

    .SHARED Read Write Shared

I am exporting two functions to access this global variable:

void SetGlobalRect(RECT rc)
    g_rcBox = rc;


RECT GetGlobalRect()
    return g_rcBox;


In my main executable calling GetGlobalRect() returns the correct values,
however when I call SetGlobalRect() my variable will not change. I know that
by default, a Microsoft DLL gives each program a private copy of a global
variable, correct? I believe what is happening is my program's copy of the
variable is changing, but not the variable in the DLL which is the one I
need to change. Any explanations?

Don Ness

Fri, 19 Nov 2004 05:39:13 GMT  
 [ 1 post ] 

 Relevant Pages 

1. Global variable or not global variable

2. How can I use/share global variables and objects in an ASP.NET application

3. Global Variables in Shared Objects

4. global variable shared by several files

5. LNK2005 - Sharing global variables

6. Shared global variables

7. Shared global variables

8. DLL Global Variables

9. global variables in a DLL

10. Watching a global variable exported by a DLL

11. Using global variables in a DLL

12. Global variables in DLL


Powered by phpBB® Forum Software