Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

McEck

exchanging data between applications

This topic is 6082 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hey guys, i want to exchange data between two applications. lets say one app asks the user for a string and i want the second app to print the string on the screen. actually, it''s more complicated. first i tried giving the address of an array to one app (with commandline switches), but that didn''t work properly. i don''t want to write the data to a file, so have you any suggestions how to exchange datas between two (or more) apps? anyway, i could do it another way in this case. well, i''ll explain my situation: i have an application unsing directx. now i want, that the user may select the rendering device. yeah, a dialog box would be fine. but the thing is, i need to include windows.h, and mfc doesn''t like that, so i can''t compile my program. now i have written a little app doing the selection-work, but how to i pass that information to my main application? any solutions would be helpfull... greetz

Share this post


Link to post
Share on other sites
Advertisement
well, i finally found a way...

for anyone who''s interested in, see this msdn-article:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ipc/datacopy_1lvd.asp

Share this post


Link to post
Share on other sites
Easiest, but definitely not safest way :

Create a DLL exporting your variable
Define your variable in a named section

// CPP file
#pragma data_seg("MYSECTION")
char buffer[1024];
#pragma data_seg()

Declare the section as shared (linker option : /SECTION:MYSECTION,RWS (read,write,share))
Link the DLL in both programs.

Now both programs can read/write to that variable.
You''ll probably need to add locks (like for threads) to prevent simultaneous access.

Share this post


Link to post
Share on other sites
If its something like selecting a rendering device in win32, you may just want to save that data to the registry and read it out in the next program.

funcs:
RegOpenKeyEx()
RegCreateKeyEx()
RegQueryValueEx()
RegSetValueEx()
RegCloseKeyEx()

Alternatively you could use some sort of inter process communication like pipes, or just invoke the 2nd app from the 1st via CreateProcess() and pass in string through command line arguments.

Share this post


Link to post
Share on other sites
anybody know how to do the data_seg() with any compilers other than msvc? i used to use it for setting global hooks, but i havent found any other way to do it

Edited by - barazor on February 23, 2002 9:59:28 PM

Share this post


Link to post
Share on other sites
quote:
Original post by barazor
anybody know how to do the data_seg() with any compilers other than msvc? i used to use it for setting global hooks, but i havent found any other way to do it



What compiler are you using ?
gcc : asm(".section whatever");

check the doc for your assembler and try to spit out the commands yourself...

Share this post


Link to post
Share on other sites
quote:
Original post by barazor
anybody know how to do the data_seg() with any compilers other than msvc? i used to use it for setting global hooks, but i havent found any other way to do it

Edited by - barazor on February 23, 2002 9:59:28 PM


You can use a memory mapped file - the hook example at winprog.org does it this way (look for it on the faq page).

Another approach to exchanging data between apps is DDE. However, it's not the easiest approach.

Edited by - lessbread on February 24, 2002 2:32:34 AM

Share this post


Link to post
Share on other sites
There''s an article on MSDN called "Inter-Process Communications". It''s in your win32 reference section. That''s what you''re talking about, and there are several options.

Share this post


Link to post
Share on other sites
quote:
Original post by McEck
i need to include windows.h, and mfc doesn''t like that, so i can''t compile my program.

now i have written a little app doing the selection-work


If I understood you correctly: Are you using a separate exe to put up a dialog box because you couldn''t include windows.h?

If that''s the case, just don''t include it and you''ll be fine. MFC includes windows.h internally. Or am I missing something here?

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!