The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: xanatose on October 12, 2011, 07:58:54 PM

Title: Question about memory mapped files.
Post by: xanatose on October 12, 2011, 07:58:54 PM
I am using memory mapped file to share memory between 2 applications. It does it work, but I want to know if there is a way for Application A receive a notification when Application B have written to the file (and what area of the file was changed).

Basically what I have in the mapped file is an array of 256 strings of exactly 256 bytes each. I want to know when each string have change.

I can think of sending a message to the window of the process, but wonder if there is another way.
Title: Re: Question about memory mapped files.
Post by: jj2007 on October 12, 2011, 08:21:27 PM
WM_COPYDATA is the standard method. You can send it from a console app, too, but of course a console cannot receive it.
By the way, you can also hand over a dword as wParam of a WM_TIMER message... not really documented but it works :bg
Title: Re: Question about memory mapped files.
Post by: dedndave on October 12, 2011, 09:28:51 PM
Quoteyou can also hand over a dword as wParam of a WM_TIMER message

cool trick   :bg

you could also register a custom user-defined message
Title: Re: Question about memory mapped files.
Post by: clive on October 12, 2011, 09:47:49 PM
Pipes? http://msdn.microsoft.com/en-us/library/windows/desktop/aa365781%28v=vs.85%29.aspx
Title: Re: Question about memory mapped files.
Post by: jj2007 on October 13, 2011, 12:31:08 AM
Quote from: dedndave on October 12, 2011, 09:28:51 PM
you could also register a custom user-defined message

or take WM_DROPFILES - works fine for a few kBytes :bg

Actually, on Win XP SP3, the "few kBytes" are exactly 624 - I pasted the complete Windows.inc into a tuned edit control, and sent it via WM_DROPFILES to another app where 638,975 bytes arrived as "first filename" ::)