Full control of the registry when creating / deleting / editing subkeys in Visual Basic.net

1

I am trying to make that by clicking on an object (called image) a value is added to the Windows registry, the point is that it does work, however, I need permission to add a subkey .. I explain:

 Imports Microsoft.Win32
Public Class Form1
Private Sub BotonAg_Click(sender As Object, e As EventArgs) Handles BotonAg.Click
    Dim h2 As RegistryKey = Registry.CurrentUser.CreateSubKey("SOFTWARE\Classes\CLSID\heey")
    h2.SetValue("heey2", &H0)
    h2.Close()
End Sub
End Class

That is, in "Classes" I can not create a new subkey, I do not have enough permissions. The code works perfectly, only I do not have permissions in Classes How can I take all the permissions? What do I need to add?

    
asked by Tamara 17.04.2017 в 09:40
source

1 answer

1

The solution I can think of for your problem is that you give administrator permission to the application.

With this then you should not have problems with Permissions in Editing the Windows Registry.

This can be done by editing the app.manifest file of the Project.

First you must go to the Properties menu of your Project. (or failing to locate the app.manifest file from the Solution Explorer).

In Project Properties you must touch the " See Windows Settings " button in the "Application" menu.

Then replace the line that says <requestedExecutionLevel level="asInvoker" uiAccess="false" /> for which it is commented and says <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

    
answered by 17.04.2017 в 14:57