|
Prev: Port MFC CCriticalSection::CSingleLock to ACE or ??? (NEWBIE ALERT)
Next: How to call DLL file from Visual C++ 4.2?
From: JD on 1 May 2008 17:05 Hi, I know it sounds against the object oriented concept. Is it possible to share a global variable among dlls? I am a OO faithful guy. However, in some very rare situations, a globally shared variable among dlls is a good solution to reduce complexity, if it's possible. Thanks. JD
From: David Lowndes on 1 May 2008 17:58 >I know it sounds against the object oriented concept. Is it possible to >share a global variable among dlls? Yes, it's possible to export/import a variable. In the MSDN topic titled "INFO: Using _declspec(dllimport) & _declspec(dllexport) in Code" see the section "Using _declspec(dllexport) and _declspec(dllimport) on Data" Dave
From: JD on 1 May 2008 18:41 Thanks Dave. I just went to read the article you quoted. Can we export a variable from a dll to another dll that is dependent on the first dll? For example, can we export a variable in .exe back to a dependent dll? Thanks for any further help. JD "David Lowndes" <DavidL(a)example.invalid> wrote in message news:e0fk145knj84r9gjg89kh0npt3thbgimc2(a)4ax.com... > >I know it sounds against the object oriented concept. Is it possible to >>share a global variable among dlls? > > Yes, it's possible to export/import a variable. > > In the MSDN topic titled "INFO: Using _declspec(dllimport) & > _declspec(dllexport) in Code" see the section "Using > _declspec(dllexport) and _declspec(dllimport) on Data" > > Dave
From: David Lowndes on 1 May 2008 19:10 >Thanks Dave. I just went to read the article you quoted. Can we export a >variable from a dll to another dll that is dependent on the first dll? For >example, can we export a variable in .exe back to a dependent dll? I don't know for sure as I've never needed to do it - give it a try! Dave
From: Doug Harrison [MVP] on 1 May 2008 20:08
On Thu, 1 May 2008 15:41:45 -0700, "JD" <jdt_young(a)yahoo.com> wrote: >Can we export a >variable from a dll to another dll that is dependent on the first dll? For >example, can we export a variable in .exe back to a dependent dll? You can do that with functions by using GetProcAddress. Don't know about variables. Accomplishing this with implicit linking is going to be harder, because you have to solve the cyclic dependency in some way. -- Doug Harrison Visual C++ MVP |