i want edit Registry key called \"usbstor\" value and this my code in update method
try
{
string path = baseRegistryKey + \"\\\\\" + Su
HKEY_LOCAL_MACHINE is always protected space in registry, so you need to either elavate privilliges to those of at least Power User or run your executable As Administrator (the one built from your solution, should be in ./bin folder) or disable UAC. Either way it will be troublesome inside Visual Studio as long as you don't have either way configured/set.
Note that if you try to use Run.. -> regedit you are also prompted by UAC, so that's not only restriction for your app but for access to registry per se.
Elevating Visual Studio before opening to Run as administrator is sufficent to edit registry from code.
For future usage you might want to create app.manifest and set your application to always require administrator privileges.
Right click on your project in Solution Explorer, then: Add -> New Item... -> Application Manifest File.
Inside your newly created application manifest, change the line:
to line
From now on it will always prompt UAC if not run as administrator.
If you run Visual Studio as not administrator, it will attempt to restart IDE as administrator, prompting to do so before proceeding.