471,072 Members | 987 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,072 software developers and data experts.

Very Important !! Sharing data between a dll and an application

//////////////// Inside the APPLICATION/ game
//how do i get the same instance running in the
//dll into my app? i.e the pointer ferrari
//does not work ! it creates a new instance in the
//app and another in the DLL even after sharing

car myferrari = getAvailableFerrari();

////////////////////INSIDE statically linked DLL
////////////////////.h /.lib /.dll

class car{
int x; // int here is used for simplicity but really i
// need an array of class instances

static car* getAvailabeFerrari()
return ferrari;

#pragma data_seg(".shared")
static car *ferrari = NULL; // pointer to class car
// app doesnt get this part ! why ?
#pragma data_seg("/SECTION:.shared",RWS)

How do i get the app to have access to the instance of the class activated in the dll ?
Or how do i share larger data through a dll .. not simple ints or strings.. these work .. can i use
// have researched MSDN and many books please help
Sep 3 '06 #1
3 4091
I also tried sharing the object itself and not a pointer , but its the same all values turn up as NULL in the APP.
pragma data_seg(".shared")
CCar ferrari();
pragma data...//same stuff goes here.. doesnt work !!

I however have a working version of the APP-DLL data sharing but the issues i get is when the second instance interferes with the first. I need only one instance and instantiated in the dll and have access to that in the app.

any clues guys?
Sep 3 '06 #2
9,065 Expert Mod 8TB
You do not need those pragmas, however you do need to use the specifier


on the data when importing into the program.

NOTE that you should not use this specifier when declaring the data in the DLL.
Sep 3 '06 #3
ok u mean like this but im tying to use stl objects... in a class ..like so

#define EXP_STL //Compiles with #define EXP_STL for dll

#ifdef EXP_STL
# define DX_API __declspec(dllexport)
# define DX_TEMPLATE
# define DX_API __declspec(dllimport)
# define DX_TEMPLATE extern

class CPipe
vector <CCounter*> CounterObjects; // Main List
vector <CCounter*> CompactList; // to pack similar funcitons
vector <CCounter*> SortedList; // sort based on higher frequency

// stack <CCounter*> slist;

vector <CCounter*>::iterator Counter_iter; // its iterator Not in use !!

size_t available_counters;
size_t total_counters;
ofstream conout;//("con");
HANDLE hConsole;

size_t getAvailableCounters(){return available_counters;}
size_t getMaxStoredCounters(){return total_counters;}

size_t getListSize(){return CounterObjects.size();}
size_t getCompactListSize(){return CompactList.size();}
size_t getSortedListSize(){return SortedList.size();}
// ofstream conout;
Sep 3 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Dennis Gavrilov | last post: by
2 posts views Thread by PeteZ | last post: by
6 posts views Thread by Yama | last post: by
3 posts views Thread by grooby | last post: by
8 posts views Thread by antonyliu2002 | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.