|
-
Sep 5th, 2002, 11:52 PM
#1
Thread Starter
PowerPoster
Make a DLL only load 1 instance through the Windows
How can i made my DLL writted in VC++ to be only have one instance in the Windows?
That mean, no matter how many times it being call by LoadLibary or using implicit link, there still using the same DLL that was loaded priviously by the same application or others application.
regards,
Chris
-
Sep 6th, 2002, 02:56 AM
#2
It IS the same DLL. That's the concept: the code will be loaded only once.
But the data is stored in seperate places for each process. There is a keyword to avoid that (some __declspec thing).
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 9th, 2002, 12:44 AM
#3
Thread Starter
PowerPoster
em... let me make my question more clearer 
let said, i have a DLL (abcdefg.dll) and there is fews variable within this Dll.
example:
IDBProperties *pIDBProperties = NULL;
and this variable must be the same through out all the application which calling the this Dll. For instance, the variable will be initialize by the first application that load the mention DLL into memory.
Then the second application load this dll. Which call one of the export function from this dll and the function will refer to this initialized varible for the rest of the code.
How this make it more clear 
regards,
Chris
-
Sep 9th, 2002, 01:50 AM
#4
Thread Starter
PowerPoster
I resolve the data segment with the following code,
#pragma data_seg("MY_SHARED_DATA")
IDBProperties *pIDBProperties = NULL;
#pragma data_seg()
#pragma comment(linker, "/section:MY_SHARED_DATA,RWS")
But i get an exception error when i execute the export function from the second exe which load the same dll.
The error code is: 120
Which mean This function is not supported on this system. from MSDN library.
why others app can used the shared variable? it that because it is a pointer?
-
Sep 9th, 2002, 04:03 AM
#5
Really strange. Might have something to do with process memory spaces. Since your var is a pointer (interface pointer), it points to a location in memory. This memory belongs to the app that first loaded your dll. It might well be that other apps can't access this memory.
Sorry, can't help you there.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Sep 9th, 2002, 07:27 PM
#6
Thread Starter
PowerPoster
i see some people doing with the interprocess syncronization by sending (SendMessage/PostMessage) own register message (RegisterWindowMessage). This can resolve some of my problem by the pointer variable remain hanging
-
Sep 9th, 2002, 07:41 PM
#7
Frenzied Member
Its called TLS (Thread Local Storage). MSDN it =).
Z.
-
Sep 10th, 2002, 04:07 AM
#8
There is some DDE technique you could use... some special message... forgot how it was called...
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|