string root = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\IniFileMapping\\Autorun.inf"; RegistryKey Rkey1 = Registry.CurrentUser.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", true); RegistryKey Rkey2 = Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer", true); RegistryKey RKey3 = Registry.LocalMachine.OpenSubKey(root, true); Rkey1.SetValue("NoDriveTypeAutoRun", 255); Rkey2.SetValue("NoDriveTypeAutoRun", 255); disable RKey3.SetValue("", "@SYS:DoesNotExist");
const bool PermissionToWriteToRegistry = true; key = Registry.CurrentUser.OpenSubKey(RootKey, PermissionToWriteToRegistry); // If the return value is null, the key doesn't exist if (key == null) { // The key doesn't exist; create it / open it key = Registry.CurrentUser.CreateSubKey(RootKey); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)