我发现了以下代码,它从注册表读取和写入。读取注册表项并在文本框中写入值
// Write a value to the registry
Microsoft.Win32.RegistryKey key;
key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey("Names");
key.SetValue("Name","Isabella");
// Get value from registry
key.GetValue("Name");
textBox1.Text = key.GetValue("Name"); // error, how can I do?
key.Close();
如何显示文本框中的值?
什么是错误? –
不能将类型'object'隐式转换为'string'。有一个明确的转换。可能丢失cast –
string value = key.GetValue(“Name”)。ToString(); [MSDN](http://msdn.microsoft.com/en-us/library/fdf576x1.aspx) – Mike