How do I create a customized keyboard layout for Windows?
The officially supported way to create a proper keyboard layout file is the MKLC (the very imaginatively named microsoft keyboard layout creator). Its graphical, but only handles the basic keys. I do believe that you should be able to do what you need off it.
There are also commercial solutions such as http://www.autohotkey.com/ (if anyone has experience with this) and non-commercial solutions such as http://sharpkeys.codeplex.com/ and AllChars (but this one doesn't seem to be maintained).