Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Sharing a data segment in a DLL

Sharing a data segment in a DLL

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mr Freeze
    wrote on last edited by
    #1

    Hi, I wrote a small dll which should be the link between two application (allow communication between them). Each application can use the dll, but the data is not shared. I had a look at the article "How to share a data segment in a DLL" by Phil McGahan to implement a shared data segment. Unfortunately this didn't work. Also the compiler always says: LINK : warning LNK4039: section "SHARED" specified with /SECTION option does not exist My dll looks basically like this: #pragma data_seg("SHARED") int counter; #pragma data_seg() #pragma comment(linker, "/section:SHARED,RWS") extern "C" __declspec(dllexport) void test() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); counter++; CString tmp; tmp.Format("Counter=%i",counter); AfxMessageBox(tmp,MB_OK|MB_ICONSTOP|MB_APPLMODAL); } What am I doing wrong :confused: :confused: Can someone help :confused: :confused: Thanks :) :)

    M 1 Reply Last reply
    0
    • M Mr Freeze

      Hi, I wrote a small dll which should be the link between two application (allow communication between them). Each application can use the dll, but the data is not shared. I had a look at the article "How to share a data segment in a DLL" by Phil McGahan to implement a shared data segment. Unfortunately this didn't work. Also the compiler always says: LINK : warning LNK4039: section "SHARED" specified with /SECTION option does not exist My dll looks basically like this: #pragma data_seg("SHARED") int counter; #pragma data_seg() #pragma comment(linker, "/section:SHARED,RWS") extern "C" __declspec(dllexport) void test() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); counter++; CString tmp; tmp.Format("Counter=%i",counter); AfxMessageBox(tmp,MB_OK|MB_ICONSTOP|MB_APPLMODAL); } What am I doing wrong :confused: :confused: Can someone help :confused: :confused: Thanks :) :)

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      You have to initialize counter (add the underlined part below): #pragma data_seg("SHARED") int counter = 0; #pragma data_seg() --Mike-- http://home.inreach.com/mdunn/ "....." -- Silent Bob :love: your :bob: with :vegemite: and :beer:

      M 1 Reply Last reply
      0
      • M Michael Dunn

        You have to initialize counter (add the underlined part below): #pragma data_seg("SHARED") int counter = 0; #pragma data_seg() --Mike-- http://home.inreach.com/mdunn/ "....." -- Silent Bob :love: your :bob: with :vegemite: and :beer:

        M Offline
        M Offline
        Mr Freeze
        wrote on last edited by
        #3

        Sounds too easy... but is working!! :cool: Thanks :rose:

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups