When using the following class in a console application, and having at least one instance of Notepad running, GetWindowThreadProcessId correctly returns a non-z
GetWindowThreadProcessId
A Windows Service has no UI, so it has no window.