Windows 7 - C# Excel Add-In - Registry.GetValue is always returning null

I don't know what's going on here... but the Microsoft.Win32.Registry class is returning all kinds of strange stuff. When I say GetSubKeys it returns a bunch of things that aren't there in regedit (for example, I call Registry.LocalMachine.OpenSubKey("SOFTWARE").SubKeyCount and it returns "81"... but there are only 30 keys when I view it using regedit)

when I try to get the value of something it always returns null.

I have gone through the registry and set permissions on various keys to everyone:full just to test, but still nothing.

am I missing something? I did just upgrade to Windows7 Ultimate from a Vista Ultimate machine...


-------------Problems Reply------------

the actual answer:

since my laptop is 64bit and my app is 32bit... it was looking under


Since you're opening HKLM, you have to ask for read-only access if you're not running as an Administrator. Just opening the key may or may not work, as Windows can't be sure you're not trying to write to it.

Changing permissions is not the solution, as it just opens a security hole that MS has been trying to close since XP (where it was voluntary to run as non-administrator) and enforcing closure of since Vista's release (where the default is non-administrator).

See this question for a discussion of this subject. It pertains to Delphi, but contains some info and links that you might find useful.

Just out of curiosity, though... Why would an Excel add-in need to read or write to HKLM? Only an installer should be writing to that hive, and file associations are stored in HKCR or HKCU.

Category:windows 7 Views:2 Time:2009-11-06

Related post

  • SPFolder.Files.Add creates the file but does return null 2010-12-16

    I'm uploading files to a document library in SharePoint 2010 by using the Add method of a SPFolder.Files object ( This worked fine, until someone made a template out of an existing library (where

  • Parsing xml: attributes.getValue() returns null? 2011-12-09

    See this part of my xml: <blocktype> <properties name="normal_blue" type="1"/> <resources image="brick_blue"/> <properties powerup="0" shield="0" /> </blocktype> I'm using this code to parse it: @Override public void sta

  • MVC 3.0 ModelBinder bindingContext.ValueProvider.GetValue(key) returns null when binding in a collection 2012-02-07

    I am new using custom ModelBinders, I have been looking around and I couldn't find any post related to this specific case. I have an entity like: public class DynamicData { public IList<DynamicDataItem> DynamicDataItems{get;set;} } In the View

  • Excel add-in does not appear after install (registry change) 2014-12-31

    Hi, To distribute my Excel add-in (= not a COM add-in) I make use of a setup-program. This setup.exe loads the Excel by setting the key HKCU\software\microsoft\office\14.0\excel\Options:OPEN[n] to the .xlam file that is the add-in. (If more than one

  • Are the XLL Excel Add-ins developed with Excel 2007 SDK portable on Windows systems without .net runtime? 2012-01-01

    I plan on developing Excel Add-ins and I have looked around on ways of getting it accomplished. What I have found from expert views on various forums whom suggest using third party XLL development environments (XLW, ExcelDNA and host of others) inste

  • WPF menu closes on mouseup when window open from excel add-in project 2011-07-20

    I have a problem when creating a menu in WPF. What happens is that it closes automatically when you stop pressing the mouse button. I want it to behave as regular menu's where you can click and the subitems will stay up but I can't find anyway to get

  • How do I deploy a VBA Excel Add-In (foo.xlam) using an msi installer? 2011-06-10

    I am a C# developer who is bundling a colleague's VBA Excel Add-In (.xlam file) with my msi installer (built using a VS Deployment project if that matters). The .xlam is placed in the application folder (C:\Program Files (x86)\MyCompany\TheProduct) d

  • create New File option in Windows - how to add Notepad to the list of programs 2012-11-13

    When I am in a particular folder, I can right click and choose New... to create a new file in that folder. The usual programs are available to choose from, like Word and Excel, and also some programs I've installed are also available. How can I add N

  • c# excel add in as dll 2009-07-16

    hi i am using vs2008+vsto to create excel add in (ribbon)... is it possible to make it a dll, like myaddin.dll so that users will have to only add this dll... and use, or can you suggest any better approach, thanks a lot! --------------Solutions-----

  • VSTO Excel add-in not loading on terminal server 2009-11-19

    My configuration is windows server 2003 (i'm logged in with admin privileges), office 2003, vtso runtime 2005 se. After installing my addin, all registry keys are in the correct locations and I have given fulltrust to my assembly using caspol.exe. My

  • Why does my Excel add-in only half work? 2010-03-09

    I've created an Excel add-in using Visual Studio 2008. It has a ribbon, a bunch of panes and code that adds sheets and ranges and gets information scraped from a web page. When I run it on my dev PC it works perfectly. I used the Publish command to p

  • Getting an unexpected "?" at the end of a Registry GetValue 2010-06-03

    I use the Registry class to manage values in the Registry on Windows Seven in C#. Registry.GetValue(...); But, I'm facing a curious behavior : Every time, the returned value is the correct one, but sometimes, it is followed by an unexpected "?" When

  • Excel Add-In deployment problem 2010-07-16

    I built an Excel add-in with VSTO 2005 SE, which I deployed to a user base that is predominantly Office 2003-based, but also with several workstations that have Office 2007 installed on them. On the Office 2003-based workstations, the add-in works pe

  • Preventing Registry.GetValue overflow 2010-11-14

    I'm trying to get the DWM colorizationColor using: Microsoft.Win32.Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\DWM").GetValue("ColorizationColor") however it is returning -2144154163 (the real value is 2150813133) I thinks this is be

  • Possible to tell which workbook called a function in an Excel Add-In (xla) 2011-02-04

    I want to write a little logging function in an excel add-in that I will be calling from many different workbooks. I'd like to be able to just call it by passing only the log text, and the log function itself could handle the timestamp, workbookname,

  • Whats wrong with Registry.GetValue? 2011-03-10

    I trying to get a registry value: var value = Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography", "MachineGuid", 0); In Windows XP all ok, but in Windows 7 returns 0. In HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Cryptography using re

  • Excel add-in password text box 2011-05-13

    I want make authentication in Excel Add-in Ribbon and sign in form is build in Ribbon (no modal window) but I need hide password characted in password text box. Ribbon don't allow add to group text box so I use edit box for enter login and password.

  • Cannot read the WMICompatibility value with Registry.GetValue 2011-06-17

    I have an IIS7 (Windows 2008 Server) and wants to check via C#, if the IIS6 Compatibility mode is enabled. I do this checking the value HKEY_LOCAL_MACHINE\\Software\\Microsoft\\InetStp\\Components","WMICompatibility" On one server this works. On anot

  • VSTO Excel Add-in deployment problem using Click Once and Mage 2011-08-11

    I have a VSTO Excel add-in that I can publish successfully from within Visual Studio 2008. I want to move the publishing into a NANT task on my CruiseControl build server so that I get all the benefits of unit testing etc. I am testing the deployment

Copyright (C), All Rights Reserved.

processed in 0.154 (s). 11 q(s)