- Joined
- Aug 4, 2021
- Messages
- 11
- Reaction score
- 3
What I want to achieve is to hide and show desktop icons by modifying the registry.
Other code will not be written, the main code is as follows:
Now it is possible to modify it, but changing i=1 to i=0 is not possible. The default registry value is 0; that is, you cannot write 0.
Other code will not be written, the main code is as follows:
C#:
try
{
int i = 1;
RegistryKey key = Registry.CurrentUser;
RegistryKey hide = key.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced", true);
hide.SetValue("HideIcons",i, RegistryValueKind.DWord);
key.Close();
Process[] MyProcess = Process.GetProcessesByName("explorer");
MyProcess[0].Kill();
}
catch (Exception ex)
{
MessageBox.Show("Error!!! \n" + ex);
}