How can I know each Win32 API function is in which DLL?
Read its documentation. Let's take, for example, the DeregisterShellHookWindow function. Although it is listed among the window functions, suggesting user32.dll, it also contains the word shell, suggesting advapi32.dll or shell32.dll (or whatever it's called). So for once, I'm not sure where to find it.
At the bottom, under the heading Function Information, is a useful little box, which tells us that, indeed, the function resides in user32.dll, that it's declared in winuser.h (but you should include windows.h), and that the import library is user32.lib, that the function is available since Windows 2000 and that both ANSI and Unicode versions exist on all systems that support it.
All the buzzt!
"There is not now, nor has there ever been, nor will there ever be, any programming language in which it is the least bit difficult to write bad code."
- Flon's Law