问题描述:

i try to insert value to registry in C# like this:

RegistryKey key;

key = Registry.CurrentUser.CreateSubKey("HKEY_LOCAL_MACHINE\\Drivers\\BuiltIn\\Touch");

key.SetValue("InitialState", 0x4, RegistryValueKind.DWord);

but nothing happand

when i insert by hand under HKEY_LOCAL_MACHINE\\Drivers\\BuiltIn\\Touch

i insert value 00000004 (Hexidecima) it works

how to do it right ?

网友答案:

You have a clear error in your statement

You try to use the CurrentUser RegistryKey to write in the LocalMachine registry hive

RegistryKey key;
key = Registry.LocalMachine.CreateSubKey("Drivers\\BuiltIn\\Touch");
key.SetValue("InitialState", 0x4, RegistryValueKind.DWord);
网友答案:

Try closing the key: key.Close(); If I remember correctly, the register is not updated until you call close(). Here's MSDN: MSDN Add Registry Key

相关阅读:
Top