我需要在vb.net(2010)中编辑注册表我知道如何在.reg文件中编辑它,但在Visual Basic 2010中却没有,如果它有助于这是代码
Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system] "dontdisplaylastusername"=dword:00000000 "legalnoticecaption"=" Justin Tech" "legalnoticetext"="This computer system, including all related equipment, is the property of the Justint Tech and is solely for uses authorized by jUSITN tECH. You have no right to privacy on the system, and all information and activity on the system may be monitored. Any unauthorized use of the system may result in disciplinary action, civil or criminal penalties." "shutdownwithoutlogon"=dword:00000001 "undockwithoutlogon"=dword:00000001
该Microsoft.Win32.RegistryKey课程将提供你需要阅读,修改和删除注册表项和值的所有功能.
例如:
using Microsoft.Win32;
...
RegistryKey myKey = Registry.LocalMachine.OpenSubKey(
@"SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system", true);
if(myKey == null)
{
myKey = Registry.LocalMachine.CreateSubKey(
@"SOFTWARE\Microsoft\Windows\CurrentVersion\policies\system",
RegistryKeyPermissionCheck.ReadWriteSubTree);
}
myKey.SetValue("dontdisplaylastusername", 0, RegistryValueKind.DWord);
myKey.SetValue("legalnoticecaption", "Justin Tech", RegistryValueKind.String);
myKey.SetValue("legalnoticetext", "This computer system...",
RegistryValueKind.String);
myKey.SetValue("shutdownwithoutlogon", 1, RegistryValueKind.DWord);
myKey.SetValue("undockwithoutlogon", 1, RegistryValueKind.DWord);
Run Code Online (Sandbox Code Playgroud)
该子项HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\policies \system实际上是存在的,我只显示了一个测试,如果你要创建自己的密钥和完整性值,你会做.