C++, DLL, shared memory using pragma without touching .DEF file

/ Published in: C++
Save to your folder(s)

myShared is an arbitrary name. It must not collide with names .bss etc (see /SECTION in MSDN).

RWS indicates Read/Write/Shared. (See /SECTION in MSDN)

Avoid sharing process-specific info such as pointers, HANDLEs etc.

Won't work with Vista Services.

Copy this code and paste it in your HTML
  1. #pragma data_seg(".myShared")
  2. #pragma comment(linker, "/SECTION:.myShared,RWS")
  3. int shared = 1; // goes in .myShared. Must be initialized.
  4. #pragma data_seg() // revert to default

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.