> My copy of MSDN, the original one that came with VC6 Enterprise (and > appears not to have been changed by installing SP5), clearly says not > to use PostMessage.
My local MSDN installation (April 2003) and the page that's currently in the online version both agree that this restriction does not exist (or, at least, they don't mention it - and I don't see why they wouldn't.) > It also says that the data you pass must not contain pointers or > references to other data, and that other threads must not alter that > data being passed. Yes, this one they mention too. > I have a theory: what if, in order to share that data, the system made > that lump of memory (in the sending ends's address space) /directly > shareable/ until the call to > SendMessage() returned? A minor violation of its own shared memory > rules? Off the top of my head, the system creates a shared memory mapped file, writes the data from the source application into it, and then makes a view of this file in the target process's address space. And the restrictions above are there are the usual ones when two threads (from the same process, or from different ones) access the same data. > If that were true, it would explain why you can't use > PostMessage: it would return before the receiving end processed it, > and the memory would no longer be accessible. > It would explain why pointers and references couldn't be > used: they wouldn't be accessible since they were not in the block of > memory you passed, and thus weren't made shareable. > I'm not sure why other threads can't change it though; perhaps doing > so would somehow invalidate the shared memory area and render it > useless (kind of like the way removing an element of a collection via > an iterator might render the iterator itself invalid, since the > collection has now changed). The PostMessage( ) call could close the handle to the MMF in the source process, and in that case, nothing would be wrong, AFAICT. But I agree that Windows might have implemented this slightly differently, in a way that renders my reasoning invalid. I guess the safe side would be not using PostMessage( ) for WM_COPYDATA. ------------- Ehsan Akhgari Farda Technology (http://www.farda-tech.com/) List Owner: [EMAIL PROTECTED] [ Email: [EMAIL PROTECTED] ] [ WWW: http://www.beginthread.com/Ehsan ] Physician, heal thyself: then you will also heal your patient. Let it be his best cure to see with his eyes the man who heals himself. -Thus Spoke Zarathustra, F. W. Nietzsche _______________________________________________ msvc mailing list [EMAIL PROTECTED] See http://beginthread.com/mailman/listinfo/msvc_beginthread.com for subscription changes, and list archive.
