Yes, in principle.
Depends on how you reinstate your TRS installation (i.e. either from a backup or a fresh install) after you rebuild your computer's operating system/ environment.
If you have a backup of your existing Trainz installation then the registration details will be re-instated too. If you start with a fresh install, inserting your User ID and Password into the Trains Options dialog box is easily accomplished too.
Good luck with it!
PC