Note that there are some explanatory texts on larger screens.

plurals
  1. POWriting to Registry (HKEY_LOCAL_MACHINE) in XP
    primarykey
    data
    text
    <p>I am trying to modify a registry key that I have been told controls whether write-caching is enabled on particular hard drives. The key should be: <code>HKEY_LOCAL_MACHINE\System\CurrentControlSet\Enum\IDE\&lt;DiskName&gt;\&lt;SerialNo&gt;\Device Parameters\Disk\UserWriteCacheSetting</code></p> <p>However I keep having problems when trying to create this key (as it doesn't exist by default). If I try to open up the <code>...\Device Parameters\Disk\</code> with write access I get a SecurityException error; "Requested registry access is not allowed". Now I have added the <code>&lt;requestedExecutionLevel level="requireAdministrator" uiAccess="false" /&gt;</code> flag to my manifest file so as to ensure I have admin access, but I'm still not having any luck.</p> <p>Any ideas would be great!</p> <pre><code> static void Main(string[] args) { RegistryKey myKey = Registry.LocalMachine.OpenSubKey("SYSTEM\\CurrentControlSet\\Enum\\IDE\\"); foreach (string driveManafacturer in myKey.GetSubKeyNames()) { RegistryKey driveKey = myKey.OpenSubKey(driveManafacturer); foreach (string driveID in driveKey.GetSubKeyNames()) { RegistryKey driveIDKey = driveKey.OpenSubKey(driveID, true); string driveType = (string)driveIDKey.GetValue("Class"); if (driveType == "DiskDrive") { RegistryKey tempKey = driveIDKey.OpenSubKey("Device Parameters\\Disk\\", true); if (tempKey == null) { tempKey = driveIDKey.CreateSubKey("Device Parameters\\Disk\\"); tempKey.SetValue("UserWriteCacheSetting", 0x0); } } } } return; } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload