Shareable 32-bit sections in a module. . .

George Cross, Borland C++ Developer Support, May 1996

Comments:
--------

So you have a 32-bit EXE and you decide you want one particular piece 
of data of which you require there to be only one instance throughout 
the entire OS no matter how many times you concurrently run the EXE.

You've also decided that doing it with memory mapped files is too 
much code.

So you read Jeffery Richter's Advanced Windows Programming and saw he
did it with Microsoft's compiler about chapter eleven, in the
MULTIINST and MODUSE programs. But you can't get the #pragma data_seg
to work with Borland's compiler.

Well just in case you thought we hadn't thought of that, we had.

Here it is.

foo.exe is our executable which maintains one instance of a variable
between multiple instances.  

Instructions
------------

1.Go to directory SHAREEXE.  Type the following,

   bcc32 @compile.rsp foo.c
   bcc32 @compile.rsp goo.c
   tlink32 @link.rsp

2.Run foo.exe multiple times concurrently.  

3.Admire and believe. 




Alternatively, perhaps you have a 16-bit DLL which has a global variable.

Many EXE's use this DLL at the same time and the global variable is used
to communicate information between EXE's.

Now your boss has asked you to port the DLL to 32-bit.  "What ?? How the 
heck am I gonna get multiple EXE's to access the same data in this 32-bit
DLL ??"  You still don't understand memory mapped files, so you start 
working on your resume.

Here is your answer.

foo.exe is our executable which loads goo.dll. Goo.dll has a global variable
of which it maintains one instance no matter how many processes concurrently
load goo.dll.

Instructions
------------

1. Go to directory SHAREDLL\DLL.  Type the following,

    bcc32 @compile.rsp goo.c
    tlink32 @link.rsp
    implib ..\exe\goo.lib goo.dll
    xcopy goo.dll ..\exe\

2. Go to directory SHAREDLL\EXE.  Type the following,

    bcc32 @compile.rsp foo.c
    tlink32 @link.rsp 

3. Run foo.exe multiple times concurrently.

4. Admire and believe.




Dedicated to Greg MacDonald, at one time Borland C++ Tech Support.


