I would like to override the close button on a third-party application so that it causes the application to be minimized instead. I do not have source code for the target application.
As far as I got researching I think I have to do something like this but I don't know how exactly:
A WH_GETMESSAGE hook to override WM_CLOSE to set the Windows status to WS_MINIMIZE.
You can do it in both C++ and C#. To do this, you would have to hook into the applications message loop and override the WM_CLOSE message to WM_MINIMIZE. To hook into any process that's running you can use:
Microsoft Detours (Commercial and not free if I remember correctly) (http://research.microsoft.com/en-us/projects/detours/)
EasyHook (Open source under LGPL) (http://easyhook.codeplex.com/)
I've used EasyHook and I was very satisfied with the results. It gives you really nice features like starting up a process with the hooks attached OR attaching hooks to already running processes. Also, it provides you with both managed(C#) and native hooking libraries. I'd recommend you take a look at it...