>I am trying to find an api or other function that I could use to make sure I am focused on the correct application. The reason... I have 5 instances of the same app running all communicating on a seperate port to handheld device's. When the device returns reply to app i need to be on the correct app. any help?
You want to check the process id against the process id of the current foreground task; this is best done using the WinAPI. I have a FAQ posted, #674, that demonstrates how to check the process in the foreground against the specific running instance in question