Esempio n. 1
0
        private static string GetInstallationPath(RegistryHive hive, RegistryKey rootKey)
        {
            OperatingSystem OS = Environment.OSVersion;
            string          result;

            // Windows XP does not have the RegGetValue. We do not care about 64-bit XP.
            if ((OS.Version.Major < 5) || ((OS.Version.Major == 5) && (OS.Version.Minor <= 1)))
            {
                RegistryKey key = rootKey.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall\winscp3_is1");
                result = (key != null) ? (string)key.GetValue("Inno Setup: App Path") : null;
            }
            else
            {
                // In .NET 4 we can use RegistryKey.OpenBaseKey(hive, RegistryView.Registry32);
                const string uninstallKey = @"Software\Microsoft\Windows\CurrentVersion\Uninstall\winscp3_is1";
                const string appPathValue = @"Inno Setup: App Path";

                result = null;

                IntPtr        data = IntPtr.Zero;
                RegistryType  type;
                uint          len   = 0;
                RegistryFlags flags = RegistryFlags.RegSz | RegistryFlags.SubKeyWow6432Key;
                UIntPtr       key   = (UIntPtr)((uint)hive);

                if (UnsafeNativeMethods.RegGetValue(key, uninstallKey, appPathValue, flags, out type, data, ref len) == 0)
                {
                    data = Marshal.AllocHGlobal((int)len);
                    if (UnsafeNativeMethods.RegGetValue(key, uninstallKey, appPathValue, flags, out type, data, ref len) == 0)
                    {
                        result = Marshal.PtrToStringUni(data);
                    }
                }
            }

            return(result);
        }
Esempio n. 2
0
 public static extern int RegGetValue(UIntPtr hkey, string lpSubKey, string lpValue, RegistryFlags dwFlags, out RegistryType pdwType, IntPtr pvData, ref uint pcbData);
Esempio n. 3
0
 public static extern int RegRestoreKey(IntPtr hKey, string lpFile, [MarshalAs(UnmanagedType.U4)] RegistryFlags dwFlags);
Esempio n. 4
0
 /// <see cref="RegistryEntry.Flags"/>
 public Builder Flags(RegistryFlags flags)
 {
     _entry.Flags = flags;
     return(this);
 }