How to Use Win32 API to Hook to Windows and Detect Mouse Clicks?

Can you please give me sample code of a Win32 console application that will hook to Windows through the API and listen for mouse clicks (all mouse clicks in the OS; not just the clicks on the app's window)?

I looked high and low for this, but couldn't find it or learn how to do it.

I'd take your code, compile it in Visual C++ Express, and learn a lot from it. I hope that it'll be my door to finally wrapping my head around Win32 API because I'll have started with a little proggy that I'm really interested in, for a change.