1

Possible Duplicate:
How to detect Windows 64 bit platform with .net?

I would like to read keys of the Uninstall subkey of Windows registry.

So in order to do that, I need to check the bit edition of OS, is the following code sufficient or not?

        public enum OSEdition
        {
            Bit32,
            Bit64
        };

        public static OSEdition GetOSEdition
        {
            get
            {
                if (System.IntPtr.Size == 8)
                {
                    return OSEdition.Bit64;
                }
                else
                {
                    return OSEdition.Bit32;
                }
            }
        } 
Community
  • 1
  • 1
mmk_open
  • 1,005
  • 5
  • 18
  • 27
  • Well there's [`Environment.Is64BitOperatingSystem`](http://msdn.microsoft.com/en-us/library/system.environment.is64bitoperatingsystem.aspx)... why not use that? – Jeff Mercado Jul 04 '11 at 06:13
  • @Jeff: It requires .NET 4 - when targetting e.g. XP and Vista, too, and the software is published via download you usually want to use a framework version that is likely to be already installed. – ThiefMaster Jul 04 '11 at 06:28
  • @Thief: Of course but nothing was specified here so I will always assume current version unless mentioned otherwise. – Jeff Mercado Jul 04 '11 at 06:32

0 Answers0