コード例 #1
0
        private static bool IsWmiTools()
        {
            var majorVersion = (int)(WinRegistry.GetValue(Constants.XenToolsRegPath, "MajorVersion", 0) ?? 0);
            var minorVersion = (int)(WinRegistry.GetValue(Constants.XenToolsRegPath, "MinorVersion", 0) ?? 0);

            return(float.Parse(majorVersion + "." + minorVersion) > 6.0);
        }
コード例 #2
0
        /// <summary>
        /// Returns the location of the common menu folder.
        /// </summary>
        /// <remarks>
        /// For retrieving the location of any other system special folders, <see cref="Environment.GetFolderPath"/> should be used.
        /// </remarks>
        /// <returns>The full path to the common menu folder, or null in case the path can't be retrieved.</returns>
        public static string GetCommonMenuFolder()
        {
            var value = HostRegistry.GetValue(
                @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\explorer\Shell Folders",
                "Common Start Menu", null);

            return(value as string);
        }
コード例 #3
0
ファイル: XnaNative.cs プロジェクト: gibbed/XCompression
        private static NativeInfo?FindAcceptableInfo(out string path)
        {
            var versions = new[]
            {
                "v4.0", "v3.1", "v3.0"
            };

            foreach (var version in versions)
            {
                var keyName = @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\XNA\Framework\" + version;
                path = Registry.GetValue(keyName, "NativeLibraryPath", null) as string;
                if (string.IsNullOrEmpty(path) == true)
                {
                    continue;
                }

                path = Path.GetFullPath(Path.Combine(path, "XnaNative.dll"));
                if (File.Exists(path) == false)
                {
                    continue;
                }

                string hash;
                try
                {
                    hash = ComputeMD5(path);
                }
                catch (FileNotFoundException)
                {
                    continue;
                }
                catch (DirectoryNotFoundException)
                {
                    continue;
                }
                catch (NotSupportedException)
                {
                    continue;
                }
                catch (UnauthorizedAccessException)
                {
                    continue;
                }

                var info = _NativeInfos.FirstOrDefault(i => i.Hash == hash);
                if (info.Valid == true)
                {
                    return(info);
                }
            }

            path = null;
            return(null);
        }
コード例 #4
0
        private void LoadShaderBundles()
        {
            try
            {
                string gamePath =
                    (string)
                    Registry.GetValue(
                        @"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\Steam App 8190",
                        "InstallLocation",
                        null);

                if (gamePath == null)
                {
                    //throw new InvalidOperationException("could not find Just Cause 2 install location");
                }

                var shaderBundlePath = Path.Combine(gamePath, "DX10_Shaders_F.shader_bundle");
                if (File.Exists(shaderBundlePath) == false)
                {
                    throw new FileNotFoundException("shader bundle is missing", shaderBundlePath);
                }

                var specialShaderBundlePath = Path.Combine(gamePath, "DX10_SpecialShaders_F.shader_bundle");
                if (File.Exists(specialShaderBundlePath) == false)
                {
                    throw new FileNotFoundException("special shader bundle is missing", specialShaderBundlePath);
                }

                using (var input = File.OpenRead(shaderBundlePath))
                {
                    this._ShaderBundle = new ShaderLibrary();
                    this._ShaderBundle.Deserialize(input);
                }

                using (var input = File.OpenRead(specialShaderBundlePath))
                {
                    this._SpecialShaderBundle = new ShaderLibrary();
                    this._SpecialShaderBundle.Deserialize(input);
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(String.Format("Failed to load shader bundles.\n\nError: {0}\n\n{1}",
                                              e.Message,
                                              e),
                                "Error",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Error);
            }
        }
コード例 #5
0
 /// <summary>
 /// Faz uma verificaçao dentro do registro do windows para saber se o tema claro/dark está ativado.
 /// </summary>
 /// <returns>Retorna uma tupla informando se o tema claro está ativo e o proprio valor que está no registro.</returns>
 public (bool @bool, string @string) TemaClaroHabilitado()
 {
     try
     {
         //verificando se o tema do windows está no claro ou escuro (light or dark)
         //retorna 0 se estiver no modo escuro
         //retorna 1 se estiver no modo claro
         //no caso eu coloquei no terceiro parametro que o valor default seria 1, ou seja, eu quero verificar se o tema do windows está como light
         //se voce mudar para 0, o metodo retornará o falor com base no dark, e nao mais no light
         object resultado = Reg.GetValue(Registro(), "AppsUseLightTheme", 1);
         return(resultado.ToString() == "1", resultado.ToString());
     }
     catch (Exception e)
     {
         MetodosConstantes.MostrarExceptions(e);
         return(false, null);
     }
 }
コード例 #6
0
        /// <summary>
        /// Returns all folders that are used as temporary folders in the current system.
        /// </summary>
        /// <returns></returns>
        public static IEnumerable <string> GetTemporaryFolders()
        {
            var folders = new List <string>(3);

            // Get user specific temporary folders.
            folders.Add(Path.GetTempPath());
            // Get system temporary folders.
            const string regSystemEnvironmentPath =
                @"HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\Environment\";
            var value = HostRegistry.GetValue(regSystemEnvironmentPath, "TEMP", null);

            if (value != null)
            {
                folders.Add(Path.GetFullPath(value.ToString()));
            }
            value = HostRegistry.GetValue(regSystemEnvironmentPath, "TMP", null);
            if (value != null)
            {
                folders.Add(Path.GetFullPath(value.ToString()));
            }
            return(folders);
        }
コード例 #7
0
 public T GetValue <T>(string registryKeyPath, string value = null, T defaultValue = default(T))
 {
     return((T)WindowsRegistry.GetValue(registryKeyPath, value, defaultValue));
 }
コード例 #8
0
ファイル: Extractor.cs プロジェクト: galek/Gibbed.MassEffect3
        private void OnLoad(object sender, EventArgs e)
        {
            var exePath = GetExecutablePath();

            string path =
                (string)Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\BioWare\Mass Effect 3", "Install Dir", null) ??
                (string)
                Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\BioWare\Mass Effect 3", "Install Dir", null);

            if (path != null)
            {
                path = Path.Combine(path, "BioGame");
                path = Path.Combine(path, "CookedPCConsole");
                this._PackagePath = path;
            }
            else
            {
                this._PackagePath = null;
            }

            var converterPath = Path.Combine(exePath, "ww2ogg.exe");

            if (File.Exists(converterPath) == false)
            {
                this.convertCheckBox.Checked = false;
                this.convertCheckBox.Enabled = false;
                this.LogError("ww2ogg.exe is not present in \"{0}\"!", exePath);
            }
            else
            {
                this._ConverterPath = converterPath;
            }

            var revorbPath = Path.Combine(exePath, "revorb.exe");

            if (File.Exists(revorbPath) == false)
            {
                this.revorbCheckBox.Checked = false;
                this.revorbCheckBox.Enabled = false;
            }
            else
            {
                this._RevorbPath = revorbPath;
            }

            this.ToggleControls(false);

            var indexPath = Path.Combine(exePath, "Wwise.idx");

            if (File.Exists(indexPath) == false)
            {
                this.LogError("Wwise.idx is not present in \"{0}\"!", exePath);
            }
            else
            {
                this.LogMessage("Loading Wwise index...");

                var uiScheduler = TaskScheduler.FromCurrentSynchronizationContext();

                DateTime startTime = DateTime.Now;

                var task = Task <List <WwiseLocation> > .Factory.StartNew(
                    () =>
                {
                    using (var input = File.OpenRead(indexPath))
                    {
                        var index = WwiseIndex.Load(input);
                        if (input.Position != input.Length)
                        {
                            throw new FormatException("did not consume entire file");
                        }

                        var locations = new List <WwiseLocation>();
                        foreach (var resource in index.Resources)
                        {
                            var firstInstance = resource.Instances
                                                .OrderByDescending(i => i.IsPackage == false)
                                                .First();

                            var location = new WwiseLocation()
                            {
                                Hash      = resource.Hash,
                                Path      = index.Strings[firstInstance.PathIndex],
                                Name      = index.Strings[firstInstance.NameIndex],
                                Actor     = index.Strings[firstInstance.ActorIndex],
                                Group     = index.Strings[firstInstance.GroupIndex],
                                Locale    = index.Strings[firstInstance.LocaleIndex],
                                File      = index.Strings[firstInstance.FileIndex],
                                IsPackage = firstInstance.IsPackage,
                                Offset    = firstInstance.Offset,
                                Size      = firstInstance.Size,
                            };

                            foreach (var instance in resource.Instances.Except(new[] { firstInstance }))
                            {
                                location.Duplicates.Add(new WwiseLocation()
                                {
                                    Hash      = resource.Hash,
                                    Path      = index.Strings[instance.PathIndex],
                                    Name      = index.Strings[instance.NameIndex],
                                    Actor     = index.Strings[instance.ActorIndex],
                                    Group     = index.Strings[instance.GroupIndex],
                                    Locale    = index.Strings[instance.LocaleIndex],
                                    File      = index.Strings[instance.FileIndex],
                                    IsPackage = instance.IsPackage,
                                    Offset    = instance.Offset,
                                    Size      = instance.Size,
                                });
                            }

                            locations.Add(location);
                        }

                        return(locations);
                    }
                });

                task.ContinueWith(
                    t =>
                {
                    var elapsed = DateTime.Now.Subtract(startTime);
                    this.LogSuccess("Loaded Wwise index in {0}m {1}s {2}ms",
                                    elapsed.Minutes,
                                    elapsed.Seconds,
                                    elapsed.Milliseconds);
                    this.LogMessage("{0} entries ({1} duplicates)",
                                    t.Result.Count,
                                    t.Result.Sum(i => i.Duplicates.Count));
                    this.OnWwiseIndexLoaded(t.Result);
                },
                    System.Threading.CancellationToken.None,
                    TaskContinuationOptions.OnlyOnRanToCompletion,
                    uiScheduler);

                task.ContinueWith(
                    t =>
                {
                    this.LogError("Failed to load Wwise index.");
                    if (t.Exception != null)
                    {
                        if (t.Exception.InnerException != null)
                        {
                            this.LogError(t.Exception.InnerException.ToString());
                        }
                        else
                        {
                            this.LogError(t.Exception.ToString());
                        }
                    }
                },
                    System.Threading.CancellationToken.None,
                    TaskContinuationOptions.OnlyOnFaulted,
                    uiScheduler);
            }
        }