在xp正常  VISTA 错误,另外求vista64位代码 或解决方案 可以加分private static bool IsInstalled(string name)
        {string uninstallKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall";
            using (RegistryKey rk =
Registry.LocalMachine.OpenSubKey(uninstallKey))
            {
                foreach (string skName in rk.GetSubKeyNames())
                {
                    using (RegistryKey sk = rk.OpenSubKey(skName))
                    {                        if ((string)sk.GetValue("DisplayName") == name)
                        {                            return true;
                        }
                    }
                }
            }            return false;        }

解决方案 »

  1.   

    在vista下即使你安装了也是错误。不知道为什么。xp下正常
      

  2.   

    可能是UAC问题..
    你试试把UAC关闭
    然后测试看看C:\Windows\System32\cmd.exe /k %windir%\System32\reg.exe ADD HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System /v EnableLUA /t REG_DWORD /d 0 /f如果要开启UAC把0改成1执行就行了
      

  3.   

    解决了 using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Security.Permissions;
    using Microsoft.Win32;[assembly: RegistryPermissionAttribute(SecurityAction.RequestMinimum,
        ViewAndModify = "HKEY_LOCAL_MACHINE")]namespace reg
    {
        class Program
        {
            private static bool IsInstalled(string name)
            {
                bool b_return = false;            string uninstallKey = @"SOFTWARE\WOW6432NODE\Microsoft\Windows\CurrentVersion\Uninstall";
                using (RegistryKey rk =
                Registry.LocalMachine.OpenSubKey(uninstallKey))
                {
                    foreach (string skName in rk.GetSubKeyNames())
                    {
                        using (RegistryKey sk = rk.OpenSubKey(skName))
                        {                        if ((string)sk.GetValue("DisplayName") == name)
                            {                            b_return = true;
                            }
                        }
                    }
                }                    if (b_return != true)
                        {
                            string uninstallKey32 = @"SOFTWARE\WOW6432NODE\Microsoft\Windows\CurrentVersion\Uninstall";
                                using (RegistryKey rk =
                                Registry.LocalMachine.OpenSubKey(uninstallKey32))
                                {
                                    foreach (string skName in rk.GetSubKeyNames())
                                    {
                                        using (RegistryKey sk = rk.OpenSubKey(skName))
                                        {                                        if ((string)sk.GetValue("DisplayName") == name)
                                            {                                            b_return = true;
                                            }
                                         }    
                                    }
                                 }
                        }            return b_return;        }        static void Main(string[] args)
            {
                if (IsInstalled("Microsoft Visual Studio Team System 2008 Team Suite - ENU"))
                {
                    Console.WriteLine("find");
                    Console.Read(); 
                }
                else
                {
                    Console.WriteLine("not find");
                    Console.Read();             }
            }
        }
    }