🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #7293

Re: Shared Memory in a DLL (C++Builder 5.0)

#7293
From: Thomas
Date: Wed, 16 Feb 2005 11:28
30 lines
1927 bytes



In C++ Builder 6.0 it is possible to create shared data segments in a DLL. I use it for a Windows
Hook procedure. I have my test software in 2 versions. The first one is made with VC++6.0 and I use 
the way you described

>A have read that for MSVC++ the right method is to use #pragma like this :
>#pragma data_seg("SHARED")
>int MyInt;
>#pragma data_seg()
>#pragma comment(linker, "/SECTION:SHARED,RWS")

In C++ Builder 6.0 I use the way you described too:

>Then, I have found that for C++Builder4.0 the right method is to use #pragma like this :
>#pragma option -zRSHSEG      // change default data segment name
>#pragma option -zTSHCLASS    // change default data class name
>int MyInt;

It is important the shared data are in a seperate file. Check out this:

http://bdn.borland.com/article/0,1410,20132,00.html

If you make your DLL with the shared data in the way the technical note shows this you will have your 
DLL with a shared data segment. I have not check if this way works with BCB5, but it works with BCB4
and I did it with BCB6.

Regards Thomas
Technical Details
Message-ID: <42132e66$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4211f77b@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,c45e9900a622f92
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Thomas" <no@mail.com>
Sender: "Thomas" <no@mail.com>
Reply-To: "Thomas" <no@mail.com>
Subject: Re: Shared Memory in a DLL (C++Builder 5.0)
Newsgroups: borland.public.cppbuilder.nativeapi
X-User-Info: 194.39.218.248     
References:  <4211f77b@newsgroups.borland.com>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <42132e66$1@newsgroups.borland.com>
Date: 16 Feb 2005 03:28:38 -0800
X-Trace: newsgroups.borland.com 1108553318 207.105.83.66 (16 Feb 2005 03:28:38 -0800)
Lines: 30
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!213.200.89.82.MISMATCH!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail