public PersistentClientLogger() { RegistryKey oxigen = null; if (!GenericRegistryAccess.RegistryKeyExists(RegistryBranch.HKLM_LOCAL_MACHINE__SOFTWARE_OxigenRef)) { _userRef = System.Guid.NewGuid().ToString(); Log("Registry__HKLM_LOCAL_MACHINE__SOFTWARE_OxigenRef"); oxigen = GenericRegistryAccess.CreateRegistryKey(RegistryBranch.HKLM_LOCAL_MACHINE__SOFTWARE_OxigenRef); } else { oxigen = GenericRegistryAccess.GetRegistryKey(RegistryBranch.HKLM_LOCAL_MACHINE__SOFTWARE_OxigenRef); } if (oxigen.GetValue("userRef") == null) { if (_userRef == null) { _userRef = System.Guid.NewGuid().ToString(); } Log("Registry__HKLM_LOCAL_MACHINE__SOFTWARE_OxigenRef_Oxigen"); oxigen.SetValue("userRef", _userRef); } else { _userRef = oxigen.GetValue("userRef").ToString(); } }
public void GetRegistryKeyTest() { string path = @"HKEY_LOCAL_MACHINE\Software\"; RegistryKey expected = null; // TODO: Initialize to an appropriate value RegistryKey actual; actual = GenericRegistryAccess.GetRegistryKey(path); Assert.AreEqual(expected, actual); Assert.Inconclusive("Verify the correctness of this test method."); }
private static bool FileRightVersionExists(string registryKey, string registryValue, string executableToCheck, int minimumVersion) { // get the installation path of the executable RegistryKey installationPathKey = GenericRegistryAccess.GetRegistryKeyReadOnly(registryKey); if (installationPathKey == null) { return(false); } object installationPathValue = installationPathKey.GetValue(registryValue); if (installationPathValue == null) { return(false); } string executableFullPath = installationPathValue.ToString() + "\\" + executableToCheck; int version; string stringVersion; try { FileVersionInfo fv = FileVersionInfo.GetVersionInfo(executableFullPath); stringVersion = fv.FileVersion.Split(new char[] { '.' })[0]; } catch { return(false); } if (!int.TryParse(stringVersion, out version)) { return(false); } if (version >= minimumVersion) { return(true); } return(false); }