(This also explains the problem from your other thread)
Services are not allowed to access the Desktop (by default). That's why FindWindow() is failing. There are ways to get around this problem, but I don't know much about Services.
My suggestion to you is this: Create a separate program that opens up a server socket (make it so that it will only accept connections from the local machine, so there would be no security issues). This program will run using the regular user on the Default Desktop. Now the second program executed by your PHP code will connect to this server and simply ask it to return the information you desire. That will solve your problems.