I can help get you started:
Start by querying for the processID that owns the window you are querying
Then open a handle with PROCESS_QUERY_INFORMATION access to the process:
With the process handle, you can get the name of the application that is running the process:
To actually get the path of some open file, it will most likely be program dependent for your information to be reliable. Possibly Explorer.exe changes the working directory for the current folder, but I dont know for sure. Document based programs you could possibly look at the open file handles for that process, but there is no guarantee for that either.
For Word and MS Office based apps specifically, I would investigate their scripting objects. They will most likely be able to report which document they are using for each process instance.