2012-01-05 71 views
0

我在写一个C#模块;我需要从注册表路径'HKEY_LOCAL_MACHINE/Software/Avtec,Inc/LicenseKey'中检索一个名为'LicenseKey'的密钥的值,并将其存储在一个名为“pml.bin”的bin文件中。我有一些代码问题。任何人都可以帮助我的代码?提前致谢。从注册表中读取值并将其存储在bin文件中

+0

你可以显示你有问题的代码吗? – 2012-01-05 06:05:22

+0

没有看到附加的截图。你还可以发布有关此事的代码吗? – dotnetnate 2012-01-05 06:05:32

+0

请点击此处链接 http://stackoverflow.com/questions/8738554/reading-value-from-registry-and-storing-it-in-a-bin-file-in-a-folder – 2012-01-05 06:32:45

回答

1

我试着用下面的代码,并没有面临任何问题。检查注册表路径并确保路径中正确的斜杠“\”。用你的代码检查下面的代码,

 RegistryKey key = Registry.LocalMachine; 
     RegistryKey dataKey = key.OpenSubKey(@"Software\Avtec.Inc\LicenseKey"); 
     string licenceKey = dataKey.GetValue("required field name").ToString(); 

     using (BinaryWriter b = new BinaryWriter(File.Open("file.bin", FileMode.Create))) 
     { 
      b.Write(licenceKey); 
      b.Close(); 
     } 
相关问题