You can call the GetForegroundWindow() function, which will return the handle to the window the user is working with. You can get certain information from its title using GetWindowText().
Next thing, you can call GetWindowLong() specifying GWL_HINSTANCE to obtain the handle to the application that created the window. GetModuleFileName() obtains the name of the executable.