In Generation IV and V, players can view their games' Friend Code by using their Pal Pad once the player has logged into Nintendo Wi-Fi Connection.
Source
Hope I helped!