Reputation: 63738
I'm thinking of Chrome & IE8 as examples of applications which have multiple processes each associated with separate windows (and other things too). How does this work? Specifically focusing on the GUI side - one question I have is does Windows treat a HWND as belonging to a process or can one process arbitrarily interact with any HWND?
Upvotes: 3
Views: 3399
Reputation: 88074
This is a great question. I'm going to throw out what I think to be a possible solution.
The primary application is responsible for spinning up additional processes (tabs) as necessary. This is very similar to spinning up additional threads.
It will use some type of inter-process commuications, such as named pipes, for transferring commands from the primary application to the additional processes and retrieving the results. For example, telling the new tab to go to a specific URL. Also, it could be used to pass some type of handle for the child process's drawing surface.
Or even just allow the parent process to set exactly where the display view point is for the child paint areas. This way you could appear to have a fully integrated app while maintaining nearly complete separation.
The key here is to define the communication point well enough. Of course, the benefit is tremendous as a dead sub process will not kill the primary application UNLESS the communications between the two are very badly written.
Further, as long as the communication points are well guarded you can effectively sandbox child processes preventing them from screwing with the host application. And, for bonus points, you could even run the child processes under limited user accounts which would further limit what damage they could do.
You might look at these sites for some examples of data sharing: http://www.catch22.net/tuts/tips#ShareData
http://msdn.microsoft.com/en-us/magazine/bb985041.aspx
Upvotes: 1
Reputation: 1
Here is the MSDN description of processes and threads. It contains a lot of good info: http://msdn.microsoft.com/en-us/library/ms681917(v=VS.85).aspx
As for a windows handle, I believe it is just a resource like any other that a process contains. However, I think that there are built in safety measures and limits as to how processes can interact with each others resources, which includes HWNDs.
Upvotes: 0
Reputation: 887469
None of these programs share a GUI among multiple processes.
Instead, they handle pages in separate processes, and route all UI interactions to the UI process.
Sharing a GUI among multiple process is possible but difficult.
Upvotes: 2
Reputation: 564433
How does this work? Specifically focusing on the GUI side - one question I have is does Windows treat a HWND as belonging to a process or can one process arbitrarily interact with any HWND?
Each HWND can be arbitrarily interacted with, mostly. For example, this post shows how to embed notepad into a Windows Forms panel.
That being said, it often causes programs to not function correctly, unless they are designed with this in mind.
Upvotes: 2