开发者

Manipulating the registry from a Click Once App

开发者 https://www.devze.com 2023-02-17 18:38 出处:网络
I have a couple applications that store data in the registry for persistence. It works great when running in Windows XP, but since upgrading to Windows 7 I\'ve noticed that it fails, basically saying

I have a couple applications that store data in the registry for persistence. It works great when running in Windows XP, but since upgrading to Windows 7 I've noticed that it fails, basically saying that the permissions are inadequate.

If I disable the UAC it seems to work fine, but I don't want to do that.

    Dim regKey As RegistryKey
    Try
        regKey = Registry.LocalMachine.OpenSubKey("Software\TagLookup", True)
        If regKey Is Nothing Then
            regKey = Registry.LocalMachine.OpenSubKey("SOFTWARE", True)
            regKey.CreateSubKey("TagLookup")
            regKey.Close()
        Else
            PrinterDeviceName = regKey.GetValue("PrinterName")
            regKey.Close()
        End If
    Catch e开发者_Go百科x As Exception
        MsgBox(ex.ToString, MsgBoxStyle.Exclamation)
    End Try


You should be writing to HKEY_CURRENT_USER, not HKEY_LOCAL_MACHINE.

0

精彩评论

暂无评论...
验证码 换一张
取 消