OK, here's a rundown of how I think this can be done. This is totally untested, so YMMV.
Create your window in the parent process. According to this page, you need to create it with the CS_OWNDC
style, which means it has the same HDC
permanently associated with it.
Launch your child process. You can pass the HWND
to it as a command line parameter, converted to hex-ascii, say, or you can devise some other method.
In the child process, call GetDC
to retrieve the HDC
of the parent's window and pass it to wglCreateContext
(I imagine you know all about doing that sort of thing).
In the child process, draw, draw, draw.
Before exiting the child process, make sure you call ReleaseDC
to free up any resources allocated by GetDC
.
This ought to work. I know that Chrome uses a separate process for each browser tab, for example (so that if the code rendering into any particular tab should crash, it affects that tab only).
Also, if you're thinking of jumping through all these hoops just because you want to reload some (different) DLLs, maybe you're looking for LoadLibrary
and GetProcAddress
instead. Hmmm, maybe I didn't need to write all that :)