Re: Accessing global variables in EXE from DLL
From: Joseph M. Newcomer (newcomer_at_flounder.com)
Date: 05/19/04
- Next message: Joseph M. Newcomer: "Re: New essay: SetWindowRgn"
- Previous message: Joseph M. Newcomer: "Re: TCHAR* and PostMessage in a thread .. memory leak question"
- In reply to: Abhijit Patait: "Accessing global variables in EXE from DLL"
- Next in thread: Jerry Coffin: "Re: Accessing global variables in EXE from DLL"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 19 May 2004 18:23:07 -0400
No. And it would be a truly lousy idea to try to do so. The word "Modularization" comes to
mind.
You could pass pointers to these variables in, but frankly, it strikes me as exceptionally
poor practice to do so. If the DLL needs state, the state should come in via a pointer to
some class that defines the DLL context.
The usual reason for this question, by the way, is most often trying to partition
poorly-written code into a DLL, where the poorly-written code uses global variables. The
way to tell it is poorly-written is that, guess what, it accesses global variables.
Putting the code in a DLL just makes the defect obvious.
joe
On 19 May 2004 12:24:05 -0700, abhi_junk@hotmail.com (Abhijit Patait) wrote:
>Is there any way I can access the global variables declared in the EXE
>file from a DLL?
>
>Thank you
>Abhijit
Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
- Next message: Joseph M. Newcomer: "Re: New essay: SetWindowRgn"
- Previous message: Joseph M. Newcomer: "Re: TCHAR* and PostMessage in a thread .. memory leak question"
- In reply to: Abhijit Patait: "Accessing global variables in EXE from DLL"
- Next in thread: Jerry Coffin: "Re: Accessing global variables in EXE from DLL"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|