Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to transfer data between VC++ projects.

Status
Not open for further replies.

avivhal

Programmer
Nov 14, 2001
9
NL
how can i transfer variable from one project to another?
for example should i write in one project:
extern int x;
x=1;

wnd in another i would like to write:
int y;
y=x;


i dont want to use assembly or writing to files but just the extern system with functions or vars.
Thanks, Aviv.
 
Hi

Well you got in fact several solutions, depending on the amount of data to exchange, the frequency and the direction of exchange.

You can consider :
- the Clipboard: potential problem if user hit Ctrl-C or X
- DDE: old-fashion but still useable
- TCP/IP¨: you can find powerful class on the Web
- Memory mapped files
- Shared memory Segments

Memory mapped files are not actual files and could be used to exchange large amount of data between apps. You'll find a class called CSharedMemory created by Jeff Prosise in
The last one, Shared memory segments, is very easy.

Simply declare this on the top of your implementation file:

#pragma data_seg( ".Shared")
BOOL bData = FALSE;
#pragma data_seg()
#pragma comment(linker, "section:.Shared,RWS")

The name of the shared segment can be what fits your need but must start with a period. You must also init the variables inside the #pragma. The type of data is what you need.

In your code, you can use bData as a normal variable.

Note that there is no synchronisation, so both can write at the same time in the same variable.

HTH

Thierry
EMail: Thierry.Marneffe@swing.be
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top