4
votes

I have a c# application and i'm trying to read "WindowsUpdate" Subkey from,

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update

it always returns null.

Code sample are given below,

Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion");
    {HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion}
        base {System.MarshalByRefObject}: {HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion}
        Handle: {Microsoft.Win32.SafeHandles.SafeRegistryHandle}
        Name: "HKEY_LOCAL_MACHINE\\Software\\Microsoft\\Windows\\CurrentVersion"
        SubKeyCount: 52
        ValueCount: 11
        View: Default
    Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\WindowsUpdate");
    null
    Registry.LocalMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\WindowsUpdate\\Auto Update");
    null
    Registry.LocalMachine.OpenSubKey("Software\\WOW6432Node\\Microsoft\\Windows\\CurrentVersion\\WindowsUpdate");
    null
1
Could you please tell me your windows platform(x86 or x64). also your application platform (x86 or x64)? - Rezoan
windows-server-2008-r2 - hupseb
only available in x64 - hupseb
Try to read x64 registry form x64 based app. otherwise you will get null response. - Rezoan
thanks Rezoan! x64 based app fixed my issue. - christopher_h

1 Answers

2
votes

Form the above comment it seems that you are trying to read x64 registry. so try to use x64 based application to read this. it should solve your problem. if you are using x86 based app to read registry form an x64 based computer then it will read from,

HKEY_LOCAL_MACHINE\Software\Wow6432Node\

insted of reading from,

HKEY_LOCAL_MACHINE\Software

and you wont read the registry key that is only available under x64 registry.