How do you edit/create registry files with C/C++?

How do you edit the reg files mainly, and if you happen to know how to create them that too I guess?