Detect whether Office is 32bit or 64bit via the registry

前端 未结 28 1053
春和景丽
春和景丽 2020-11-29 21:29

Now that Office also comes in a 64bit install, where in the registry do you find out if the version of Office installed is 32bit or 64bit?

28条回答
  •  离开以前
    2020-11-29 22:10

    EDIT : Solution without touching RegistryKeys - im Sorry Op.

    I found out that there is a solution in C# - the original can be found here : https://blogs.msdn.microsoft.com/webdav_101/2016/07/26/sample-detecting-installed-outlook-and-its-bitness/

    I modified it a bit for my needs.

    just pass the correct outlookPath to GetOutlookBitness()

      public enum BinaryType : uint
    
        {
            SCS_32BIT_BINARY = 0, // A 32-bit Windows-based application
            SCS_64BIT_BINARY = 6, // A 64-bit Windows-based application.
            SCS_DOS_BINARY = 1, // An MS-DOS – based application
            SCS_OS216_BINARY = 5, // A 16-bit OS/2-based application
            SCS_PIF_BINARY = 3, // A PIF file that executes an MS-DOS – based application
            SCS_POSIX_BINARY = 4, // A POSIX – based application
            SCS_WOW_BINARY = 2 // A 16-bit Windows-based application
        }
    
    
    
        [DllImport("kernel32.dll")]
        static extern bool GetBinaryType(string lpApplicationName, out BinaryType lpBinaryType);
    
    
    
    
        public int GetOutlookBitness(string FilePath)
        {
            int bitness = 0;
    
            if (File.Exists(FilePath))
            {
                BinaryType type;
                GetBinaryType(FilePath, out type);
    
    
                switch (type)
                {
                    case BinaryType.SCS_32BIT_BINARY:
                        bitness = 32;
                        break;
                    case BinaryType.SCS_64BIT_BINARY:
                        bitness = 64;
                        break;
                }
            }
    
            return bitness;
    
    
    
        }
    

提交回复
热议问题