Click here to Skip to main content
15,892,517 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: validation Pin
mpapeo4-Apr-05 10:30
mpapeo4-Apr-05 10:30 
GeneralRe: validation Pin
David Crow4-Apr-05 10:38
David Crow4-Apr-05 10:38 
GeneralRe: validation Pin
mpapeo4-Apr-05 11:01
mpapeo4-Apr-05 11:01 
GeneralRe: validation Pin
mpapeo4-Apr-05 12:01
mpapeo4-Apr-05 12:01 
GeneralRe: validation Pin
David Crow4-Apr-05 17:03
David Crow4-Apr-05 17:03 
GeneralRe: validation Pin
David Crow4-Apr-05 17:01
David Crow4-Apr-05 17:01 
Generalglobal variables in dynamic link library Pin
arthi_mclt3-Apr-05 23:05
arthi_mclt3-Apr-05 23:05 
GeneralRe: global variables in dynamic link library Pin
Alexander M.,4-Apr-05 2:53
Alexander M.,4-Apr-05 2:53 
Global varible does NOT mean global concerning multiple processes!!
That global just means then you can access it from every function of ONE process.
If you want to access the variable from multiple processes then you have to share it!

To make it more clear:
The DLL file format (called PE file format) consists of sections. These section can have different settings. You code normally uses a section called .text, and the global variables use .data.
When a DLL is attached to a process, the sections are checked whether they contain data or code, and weather they sould be shared accross the whole system.
If sharing is not used, then the .text section is loaded and initialized by the code from the DLL file, but the .data section gets NEW memory, which is then initialized by the main function of the DLL file.
That would mean, that every process with the DLL attached to it, there is a completly new .data section which has different physical addresses in your RAM.

So when you want to share such a global variable over many processes, then you need to add a new shareable section or modify the whole .data section to make it shareable (which is not very reasonable).

To create a new section use this code:

#pragma data_seg( ".share" )
/* The variables go in here */
HANDLE hFileHandle = 0;
/* whatever ... */
#pragma data_seg()

#pragma comment( linker, "/SECTION:.share,RWS" )



Don't try it, just do it! Wink | ;-)
GeneralText display with CHtmlView Pin
lordguid3-Apr-05 22:48
lordguid3-Apr-05 22:48 
GeneralRichEdit and Console Pin
AdyOS3-Apr-05 22:36
AdyOS3-Apr-05 22:36 
GeneralRe: RichEdit and Console Pin
toxcct3-Apr-05 22:39
toxcct3-Apr-05 22:39 
GeneralRe: RichEdit and Console Pin
AdyOS3-Apr-05 23:00
AdyOS3-Apr-05 23:00 
GeneralRe: RichEdit and Console Pin
toxcct3-Apr-05 23:22
toxcct3-Apr-05 23:22 
GeneralRe: RichEdit and Console Pin
S. Senthil Kumar3-Apr-05 23:24
S. Senthil Kumar3-Apr-05 23:24 
GeneralRe: RichEdit and Console Pin
AdyOS3-Apr-05 23:33
AdyOS3-Apr-05 23:33 
GeneralRe: RichEdit and Console Pin
AdyOS3-Apr-05 23:58
AdyOS3-Apr-05 23:58 
GeneralVxDs vs DLL Pin
Neha.marwaha3-Apr-05 22:25
Neha.marwaha3-Apr-05 22:25 
GeneralRe: VxDs vs DLL Pin
toxcct3-Apr-05 22:36
toxcct3-Apr-05 22:36 
GeneralRe: VxDs vs DLL Pin
Alexander M.,4-Apr-05 2:40
Alexander M.,4-Apr-05 2:40 
General0L Pin
LiYS3-Apr-05 21:41
LiYS3-Apr-05 21:41 
GeneralRe: 0L Pin
toxcct3-Apr-05 22:32
toxcct3-Apr-05 22:32 
GeneralRe: 0L Pin
Gary R. Wheeler4-Apr-05 2:05
Gary R. Wheeler4-Apr-05 2:05 
GeneralRe: 0L [edited] Pin
toxcct4-Apr-05 3:14
toxcct4-Apr-05 3:14 
GeneralRe: 0L Pin
Tim Smith4-Apr-05 3:56
Tim Smith4-Apr-05 3:56 
GeneralRe: 0L Pin
toxcct4-Apr-05 5:34
toxcct4-Apr-05 5:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.