Article View: borland.public.cppbuilder.nativeapi
Article #9789Same memory piece for 2 running applications?
From: Ramy
Date: Tue, 08 Jun 2004 09:57
Date: Tue, 08 Jun 2004 09:57
71 lines
2937 bytes
2937 bytes
Hi, if you remember i asked here this question not long ago.
I need to write 2 applications which runs at the same time on the
computer (Windows-2000) and share same piece of memory for
exchanging data between each other (this piece of memory will
contain a matrix of 400 x 500 float numbers (or 'int' , i still
don't know) so if for example one application change this matrix,
the anther application can take the matrix from the memory and
use it, or display it for example...
Can i allocate an array like this -
float array[500][400];
then write it's address ( &array[0][0] ) and size (500x400) in
a file, so the other application can read the file and access
the array by using the pointer and the size from this file?
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
This is what i tried to do and it's not working OK -
First i run the 'Master' application and press it's button -
int MyBuff[50], *BuffPtr = NULL; // Globals
void __fastcall TForm1::SpeedButton1Click( TObject *Sender )
{
MyBuff[0] = 1;
MyBuff[1] = 2;
MyBuff[2] = 3;
MyBuff[3] = 7;
MyBuff[4] = 11;
MyBuff[5] = 13;
MyBuff[6] = 17;
MyBuff[7] = 21;
BuffPtr = &MyBuff[0];
MyBuff[8] = 99;
}
and i can see that BuffPtr points to the address 0x40371C.
then (without stopping the 'Master' running) i'm running the
'Slave' application and press it's button which have the code -
int MyBuff[50], *BuffPtr = NULL; // Globals
void __fastcall TForm1::SpeedButton1Click( TObject *Sender )
{
BuffPtr = (int *)0x40371C; // Same address as i saw in master!
MyBuff[0] = BuffPtr[0];
MyBuff[1] = BuffPtr[1];
MyBuff[2] = BuffPtr[2];
MyBuff[3] = BuffPtr[3];
MyBuff[4] = BuffPtr[4];
MyBuff[5] = BuffPtr[5];
MyBuff[6] = BuffPtr[6];
MyBuff[7] = BuffPtr[7];
}
But Although that i see that 'BuffPtr' points to the same
address in the 2 applications (0x40371C) in the 'Slave' watch i
see that MyBuff[] buffer have 0 in all it's cells, and not
as i expected to see, the numbers 1, 2, 3, 7.... which i set in
the 'Master'.
Why does it not working? please.
Thanks,
Ramy
Technical Details
Message-ID:
<40c58d7a$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!feed.news.schlund.de!schlund.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,1b6c238d7724ed66,start X-Google-Attributes: gid10cc67,public From: "Ramy" <Ramy@NoMail.com> Sender: "Ramy" <Ramy@NoMail.com> Reply-To: "Ramy" <Ramy@NoMail.com> Subject: Same memory piece for 2 running applications? Newsgroups: borland.public.cppbuilder.nativeapi X-User-Info: 62.0.27.152 NNTP-Posting-Host: 207.105.83.66 Message-ID: <40c58d7a$1@newsgroups.borland.com> Date: 8 Jun 2004 02:57:14 -0700 X-Trace: newsgroups.borland.com 1086688634 207.105.83.66 (8 Jun 2004 02:57:14 -0700) Lines: 72 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!feed.news.schlund.de!schlund.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail