making a global variable accessible in a DLL function

Mar 20, 2009 at 10:48am
Hello,

I have a question about how to make an application global variable be accessible from a DLL.

The problem is that some of the classes that this DLL uses need access to a logging object that is a global object instantiated by the application. Whenever the call from the DLL accesses this object, I get a crash.

I was wondering if there is a way to access this global object from a function called by the DLL?

Thanks,

Luca
Mar 20, 2009 at 11:23am
You should post this in the Windows section as it's OS specific.

In answer to the question, you need to export the data as you would a function.
Mar 20, 2009 at 11:41am
do a __declspec(dllimport) instead of __declspec(dllexport)
i think it will work.

you do an export from dll when you access something in the dll from a .exe. similarly to access something in dll from .exe you need to import that way.
Topic archived. No new replies allowed.