It seems TApaTaskList::FindByPos(0) method can help you.
It returns TApaTask of the foreground application.