How to check Win7 or 64bit environment

来源:互联网 发布:unity3d人物行走代码 编辑:程序博客网 时间:2024/04/28 01:20

private static string ProgramFilesx86()

        {

            if (8 == IntPtr.Size

                || (!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("PROCESSOR_ARCHITEW6432"))))

            {

                return Environment.GetEnvironmentVariable("ProgramFiles(x86)");

            }

 

            return Environment.GetEnvironmentVariable("ProgramFiles");

        }

string programeMenuPath = ProgramFilesx86();

 

 

 

[DllImport("shell32.dll")]

        static extern bool SHGetSpecialFolderPath(IntPtr hwndOwner, [Out] StringBuilder lpszPath, int nFolder, bool fCreate);

        const int CSIDL_COMMON_STARTMENU = 0x16; 

StringBuilder stringBuilder = new StringBuilder(1000);

                SHGetSpecialFolderPath(IntPtr.Zero, stringBuilder, CSIDL_COMMON_STARTMENU, false);

                string shortCutPath = Path.Combine(stringBuilder.ToString(), "Programs");