Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect "Bitness" Determined if Outlook is not installed #19

Open
lsowen opened this issue Apr 10, 2021 · 1 comment
Open

Incorrect "Bitness" Determined if Outlook is not installed #19

lsowen opened this issue Apr 10, 2021 · 1 comment

Comments

@lsowen
Copy link

lsowen commented Apr 10, 2021

We have some limited installations of Office which do not include Outlook. In this case, the 32 bit XLL is incorrectly registered, because the "bitness" registry entry for Outlook is used to determine if 32 or 64 bit should be used:

RegistryKey rkBitness = localMachineRegistry.OpenSubKey(@"Software\Microsoft\Office\" + szOfficeVersionKey + @"\Outlook", false);

@Shane8th
Copy link

Shane8th commented Feb 14, 2024

This is some years late, but someone else might ask.

In the Product.wxs in the CustomAction.cs file goto the GetAddInName function and add a check for the registry key
"Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office\ClickToRun\Configuration\Platform"

This will have the platform in here too, might solve your issue.

eg.

// Check click to run installs for bitness first, just incase Outlook is not installed
RegistryKey clickToRunPlatform = localMachineRegistry.OpenSubKey(@"SOFTWARE\Microsoft\Office\ClickToRun\Configuration", false);
if (clickToRunPlatform != null)
{
    object platformValue = clickToRunPlatform.GetValue("Platform");
    if (platformValue != null)
    {
        if (platformValue.ToString() == "x64")
        {
            return szXll64Name; // Exit early since platform is x64
        }
    }
}

Failing this, you could try getting the binary type of excel application its self, you can also find the binary path of excel in registry in here "Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths"

eg

  private const ushort SCS_32BIT_BINARY = 0;
  private const ushort SCS_64BIT_BINARY = 6;

  [DllImport("kernel32.dll")]
  private static extern bool GetBinaryType(string lpApplicationName, out ushort lpBinaryType);

  private static ushort GetBinaryType(string filePath)
  {
      if (!GetBinaryType(filePath, out ushort result))
          throw new Exception("Error while calling GetBinaryType");

      return result;
  }
 RegistryKey pathKey = localMachineRegistry.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\excel.exe", false);
 if (pathKey != null)
 {
     object pathValue = pathKey.GetValue(null);
     if (pathValue != null)
     {
         var excelPath = pathValue.ToString();

         if (!string.IsNullOrEmpty(excelPath) && File.Exists(excelPath))
         {
             if (GetBinaryType(excelPath) == SCS_64BIT_BINARY)
             { 
                 return szXll64Name;
             }
         }
     }
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants