> My original confusion was thinking that I could not share even an HWND
> across threads; but of course, this is wrong - you CAN - it's the CWnd
> pointer wrapping it that can't be shared. My bad.
>
> So can ALL HANDLEs be shared? E.g., one created by CreateFile()?

I didn't mean you can share *all* HANDLES; just sync object HANDLEs (like a
mutex handle, an event handle, or a semaphore handle.)

Of course you could share a file HANDLE, but you *can't* write to it from
multiple threads at once, or you will probably corrupt the file.  CWnd's are
a different matter, since MFC maintains some per-thread information about
some of its objects (CWnd's included) which will render incorrect in the
context of other threads.

My whole point was, you don't need to protect access to a sync object; a
sync object is protecting access to some other object!  :-)

> A DLL counts as the same process as an app, because it is mapped into
> the application's address space - correct?

Yes.

> What about an OCX? Same process, or not? Automation of a server
> embedded in an EXE is clearly not the same process since it's a
> separate EXE... but I'm wondering about a proper .OCX file?

DLLs hosting COM object (let's call them COM DLL servers, including OCXs)
are a bit different.  If they're inproc, then they will be loaded within the
calling process's address space.  If they're marked out-of-proc in the
registry, they will be loaded within a host exe (dllhost.exe, most likely)
to/from which the COM calls will be marshaled.

But as far as ActiveX objects are concerned, I have never come across one
that is not inproc, and I *think* that they can't actually be out-of-proc,
but you need to check the MSDN for that.  Please note that for a COM DLL
server to access anything that's not directly passed to it in the calling
process's address space is at best considered bad practice, and at worst
will crash the whole thing (for out-of-proc servers.)  Anything it needs
must be passed to it.  That is what COM's interface abstractions are all
about.

-------------
Ehsan Akhgari

Farda Technology (http://www.farda-tech.com/)

List Owner: [email protected]

[ Email: [EMAIL PROTECTED] ]
[ WWW: http://www.beginthread.com/Ehsan ]

An instrument of your body is also your small wisdom, my brother, which you
call "mind"- a little instrument and toy of your great wisdom.
-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.

Reply via email to