I got this message the other night after running one of these to try and see which CD key I was using (gav was trying to reinstall his BF2 on Win7):-
C:\Program Files\EA GAMES\Battlefield 2\Support\
Battlefield 2_code.exe
EasyInfo.exe
Then when trying to join a server it would kick me to the multiplayer screen with the message:-
CD-Key not valid
This was the only thing I found that worked without me having to do a full reinstall of BF2:-
BF2 CD-Key not valid anymore? WTF!? If anyone ever gets this problem, just have a skim over that thread. I found that I only needed to change the entry in regedit to fix it. Everything else he says was unnecessary.
Open regedit (start > run > regedit)
Go to HKey_Local_Machine\Software\Electronic Arts\EA Games\Battlefield 2\erg
I had one entry names Default
Change it so it has your CD Key there (altogether without spaces or dashes) but make sure it starts with x9232