Board index » Visual Studio » Need only one DLL instance to run...
|
Verne
|
|
Verne
|
Need only one DLL instance to run...
Visual Studio81
Hi all, 1: if two apps load the same DLL - LoadLibrary(...) - system will create to different instance of the DLL... Now, in my DLL i've a CList and i need it to be visible to all instance and all apps!!!! Is there a way!? 2: I need the dll to remain loaded till machine reboot!!! Is it possible!? Thanks Ale - |
| David
Registered User |
Thu Sep 08 08:19:01 CDT 2005
Re:Need only one DLL instance to run...Quoteif two apps load the same DLL - LoadLibrary(...) - system will create to You can share simple data in a DLL if you specify the data in a shared section: #pragma comment(linker, "/SECTION:.shared,RWS") #pragma data_seg(".shared") HWND g_hWnd = NULL; // Shared data must be initialised #pragma data_seg() However, for larger data, a named memory mapped file may be a better solution. Quote2: then you can. Dave -- MVP VC++ FAQ: www.mvps.org/vcfaq">www.mvps.org/vcfaq - |
| Ale
Registered User |
Thu Sep 08 08:51:06 CDT 2005
Re:Need only one DLL instance to run...
Ok, thanks for your answare...
Ale "David Lowndes" wrote: Quote>if two apps load the same DLL - LoadLibrary(...) - system will create to |
| Joseph
Registered User |
Fri Sep 09 10:13:31 CDT 2005
Re:Need only one DLL instance to run...
You can't share a CList. You can't have anything IN the CList that requires 'new',
including CStrings. If you do a shared-data-segment DLL, every bit you need to share must be statically declared in the sharable data segment. If you do a memory-mapped-file sharing, likewise. You will have to build your own "storage allocator" in these if you need dynamic allocation, and if you do this, you need to use fixed-sized blocks if possible so you avoid memory fragmentation of a very scarce resource. In addition, you have no guarantees that the block of memory is mapped into the same addresses in each process (if the debugger tells you this is so, take this as sheer coincidence! You cannot force the mappings to be the same, although the OS will tend to favor identical mappings it is not guaranteed). Thus, you must used __based pointers to put any pointers into this area. I use this exact problem in my System Programming course. Send me private email and I'll send you a working example of how this is done. joe On Thu, 8 Sep 2005 03:43:02 -0700, Ale <Ale@discussions.microsoft.com>wrote: QuoteHi all, Web: www.flounder.com">www.flounder.com MVP Tips: www.flounder.com/mvp_tips.htm">www.flounder.com/mvp_tips.htm - |
