15 мая 2023 года "Исходники.РУ" отмечают своё 23-летие!
Поздравляем всех причастных и неравнодушных с этим событием!
И огромное спасибо всем, кто был и остаётся с нами все эти годы!

Главная Форум Журнал Wiki DRKB Discuz!ML Помощь проекту


Sharing data in a DLL

P. Senthil -- senthilp@geocities.com
Tuesday, February 18, 1997

Environment: VC++ 1.52, Win 95

I want to maintain an array of pointers that is to be shared across
instances of an _AFXDLL DLL. Please note that this is a 16 bit
environment.

I had a global static CPtrArray. But the problem is that CPtrArray
allocates internal data members on the heap. So, when two applications
are using the DLL and one application quits, the heap is destroyed and
corrupts the internal data structure (whatever it allocates for holding
the pointer value) of the CPtrArray.

Can I have a new operator to be used only by the CPtrArray which could
use Global allocations? Or is there a better way to salvage CPtrArray
for such cases?

P. Senthil
mail: senthilp@geocities.com
www : http://www.geocities.com/SiliconValley/Heights/6504



Manny Powers -- mpowers@cts.com
Tuesday, February 18, 1997

[Mini-digest: 2 responses]

> Environment: VC++ 1.52, Win 95
> 
> I want to maintain an array of pointers that is to be shared across
> instances of an _AFXDLL DLL. Please note that this is a 16 bit
> environment.

Hi,

What you want to read is a great article by Ted Faison in the June MSJ 1994
called "A Primer on Building Server-Style DLLs for Windows With MFC 2.5 and
OWL 2.0".

HTH,
Manny
-----From: Erik Funkenbusch 

There are probably a dozen different ways to accomplish data sharing in =
Win16.

AFXDLL's are a strange kind of DLL.  They use the applications heap for =
memory management instead of the DLL's heap.  This is so that Classes =
derived from other classes can work properly across DLL boundaries among =
other reasons.

If you think there's a chance this could ever be ported to a 32 bit =
environment, you might want to consider a different way to share data, =
such as using OLE.

The easiest way to solve your problem would be to make the DLL a USRDLL =
instead of an AFXDLL, if it's only purpose is to share data.  If the DLL =
does other things, then you might want to consider creating a DLL only =
for sharing the memory.

-----Original Message-----
From:	P. Senthil [SMTP:senthilp@geocities.com]
Sent:	Monday, February 17, 1997 10:54 PM
To:	mfc-l@netcom.com
Subject:	Sharing data in a DLL

Environment: VC++ 1.52, Win 95

I want to maintain an array of pointers that is to be shared across
instances of an _AFXDLL DLL. Please note that this is a 16 bit
environment.

I had a global static CPtrArray. But the problem is that CPtrArray
allocates internal data members on the heap. So, when two applications
are using the DLL and one application quits, the heap is destroyed and
corrupts the internal data structure (whatever it allocates for holding
the pointer value) of the CPtrArray.

Can I have a new operator to be used only by the CPtrArray which could
use Global allocations? Or is there a better way to salvage CPtrArray
for such cases?

P. Senthil
mail: senthilp@geocities.com
www : http://www.geocities.com/SiliconValley/Heights/6504




Become an MFC-L member | Вернуться в корень Архива |