You can do this in both C ++ and C #. To do this, you have to connect to the application message loop and redefine the WM_CLOSE message to WM_MINIMIZE. To connect to any running process, you can use:
Microsoft Detours (commercial and not free, if I remember correctly) (http://research.microsoft.com/en-us/projects/detours/)
EasyHook (Open source for LGPL) (http://easyhook.codeplex.com/)
I used EasyHook and I was very pleased with the results. This gives you really nice features, such as starting a process with hooks attached OR attaching hooks to already running processes. In addition, it provides you with both managed (C #) and proprietary connection libraries. I would recommend you take a look at it ...
source share