How can I write and read from the registry?