share data between apps using a dll : #pragma data problem

Hello from Argentina !!!, I'm trying to communicate to programs using a DLL (this would be an IPC) . The first program calls a function in the dll and writes a variable "k". Then the second program call another function in the same dll and reads this variable "k". The problem, as you surely know, is that each program loads it's own copy of the dll and they are not seeing the same "k". So the solution will be using a memory shared section using the pragma command....but I canĀ“t make this work!!, please help me!

The cpp code of the dll:
//****************************************************************************
#include "dll.h"
#include <windows.h>
#include <malloc.h>
#include <memory.h>
#include <math.h>
#include <float.h>
#include <iostream>
#include <fstream>
#include <stdio.h>

using namespace std;

#pragma data_seg("SHARED")
double k=0;
#pragma data_seg()
#pragma comment(linker, "/section:SHARED,RWS")


//function 1

extern "C" double WINAPI _export WinINT1(double input)
{
k=input;
return(k);


}

//function 2

extern "C" int WINAPI _export test(double x[99], double y[99])
{



y[0] = k;

return (0); //0 means no error, other values may be displayed as warnings
}

//*****************************************************************************
Topic archived. No new replies allowed.