Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!sun-barr!newstop!eastapps!tandoori!venkat From: venkat@tandoori.East.Sun.COM (Desikan Venkatrangan - Sun BOS Software CONTRACTOR) Newsgroups: comp.windows.ms.programmer Subject: Re: Global Memory Goes Away? Message-ID: <6096@eastapps.East.Sun.COM> Date: 13 May 91 14:30:39 GMT References: <1639@msa3b.UUCP> Sender: news@East.Sun.COM Reply-To: venkat@east.sun.com (Desikan Venkatrangan - Sun BOS Software CONTRACTOR) Organization: Sun Microsystems, Billerica MA Lines: 20 In article <1639@msa3b.UUCP> kevin@msa3b.UUCP (Kevin P. Kleinfelter) writes: >I allocate some memory with "GlobalAlloc(GMEM_MOVEABLE|GMEM_ZEROINIT,2048)" >in instance 1 of my program. I store the handle to this memory in a >class extra word. Instance 2 shares this memory, by getting the handle from >the class word. > >This works fine, until instance 1 terminates; at this point instance 2 >can no longer GlobalLock. It looks like Windows is calling GlobalFree >for me. Other than writing a DDE for sharable memory, how can I prevent the >freeing and allow sharing? > The Windows SDK Guide to Programming, Section 16.5 "Traps to Avoid Managing Program Data" specifically says that "You may not use a global handle to share data with another application". It also says that "The only methods supported by Windows to pass data between applications are the clipboard and the DDE protocol". There are many more problems you have not run into yet, some of which are explained in that section.