I think it's similar to the procedure you mentioned, but I don't think the providers write the lock code in the phone themselves.
It will definitely not work for every phone of the same carrier, that would be very bad for them ;)
Just imagine one person gets it's code and publishes it on the internet. Suddenly all the phones of the carrier would be unlocked :D




