Windows 8中的注册表 [英] Registry in Windows 8

查看:98
本文介绍了Windows 8中的注册表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个代码

I have this code

Dim regKey As RegistryKey
regKey = Registry.LocalMachine.OpenSubKey("Software", False)
regKey.CreateSubKey("MyApp")
regKey.Close()
MsgBox("Registry key HKLM\Software\MyApp created")



一切正常但是在

windows 8 64bit我有此错误消息

mscorlib.dll中发生了'System.UnauthorizedAccessException'类型的未处理异常

有没有人有Windows 8.1 64位的示例代码



谢谢


in windows xp its all ok but in
windows 8 64bit I have this error message
"An unhandled exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll"
Does anyone have an example code for windows 8.1 64 bit

Thanks

推荐答案

不要使用注册表。

从Vista开始,访问已成为更多 而且受到更多限制,因为它被滥用并变得非常臃肿。写入注册表需要提升权限 - 这意味着阿联酋 - 对于任何新事物都是一个糟糕的选择。



看看这里:我应该在哪里存储我的数据? [ ^ ] - 它建议一些更安全的地方来存储信息。
Don't use the registry.
Beginning in Vista, access has become more and more restricted because it was abused and became badly bloated. Writing to the registry needs elevated permissions - which means UAE - which is a poor choice for anything new.

Have a look here: Where should I store my data?[^] - it suggests some safer places to store information.


尝试以下代码

try below code
Dim regKey As RegistryKey
regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE", True)
regKey.CreateSubKey("MyApp")
regKey.Close()





查看文档RegistryKey.OpenSubKey方法(字符串,布尔值) [ ^ ]

您需要将true值作为可写参数给出。否则你打开为只读模式



check the documentation of RegistryKey.OpenSubKey Method (String, Boolean)[^]
you need to give true value as writable parameter. otherwise you open as read only mode


这篇关于Windows 8中的注册表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆