Article View: borland.public.cppbuilder.nativeapi
Article #9817Re: Same memory piece for 2 running applications?
From: Ramy
Date: Wed, 09 Jun 2004 06:37
Date: Wed, 09 Jun 2004 06:37
42 lines
2328 bytes
2328 bytes
Thanks very very much! "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com> wrote: > >"Ramy" <Ramy@NoMail.com> wrote in message >news:40c58d7a$1@newsgroups.borland.com... > >> 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 > >Use a named file mapping to share a block of memory between the two >programs. Look at CreateFileMapping() and MapViewOfFile(). When both >applications call CreateFileMapping() using the same name, they will get a >handle to the same global mapping object. Then MapViewOfFile() can turn >that object into a pointer that both applications can then use to access the >shared memory. > >> 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... > >Just make sure that you provide adequate synchronization, such as via a >named mutex. > >> 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? > >No. Applications have their own address spaces. They cannot access each >other's memory directly. The value of a pointer in one application may not >be a meaningful value in another program. > >Gambit
Technical Details
Message-ID:
<40c6b024$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!newsfeed.tpinternet.pl!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<40c58d7a$1@newsgroups.borland.com> <40c5fb45$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,1b6c238d7724ed66 X-Google-Attributes: gid10cc67,public From: "Ramy" <Ramy@NoMail.com> Sender: "Ramy" <Ramy@NoMail.com> Reply-To: "Ramy" <Ramy@NoMail.com> Subject: Re: Same memory piece for 2 running applications? Newsgroups: borland.public.cppbuilder.nativeapi X-User-Info: 62.0.27.152 References: <40c58d7a$1@newsgroups.borland.com> <40c5fb45$1@newsgroups.borland.com> NNTP-Posting-Host: 207.105.83.66 Message-ID: <40c6b024$1@newsgroups.borland.com> Date: 8 Jun 2004 23:37:24 -0700 X-Trace: newsgroups.borland.com 1086763044 207.105.83.66 (8 Jun 2004 23:37:24 -0700) Lines: 43 Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!proxad.net!newsfeed.tpinternet.pl!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail