internal static void RunningVersions(TraceLogger TL) { AppDomain currentDomain = AppDomain.CurrentDomain; OperatingSystem osVersion = Environment.OSVersion; try { TL.LogMessage("Versions", "Main Process: " + Process.GetCurrentProcess().MainModule.FileName); FileVersionInfo fileVersionInfo = Process.GetCurrentProcess().MainModule.FileVersionInfo; TL.LogMessageCrLf("Versions", " Product: " + fileVersionInfo.ProductName + " " + fileVersionInfo.ProductVersion); TL.LogMessageCrLf("Versions", " File: " + fileVersionInfo.FileDescription + " " + fileVersionInfo.FileVersion); TL.LogMessageCrLf("Versions", " Language: " + fileVersionInfo.Language); TL.BlankLine(); } catch (Exception ex) { //ProjectData.SetProjectError(ex); Exception exception = ex; TL.LogMessage("Versions", "Exception EX0: " + exception.ToString()); //ProjectData.ClearProjectError(); } try { TL.LogMessage("Versions", "OS Version: " + Conversions.ToString((int)osVersion.Platform) + ", Service Pack: " + osVersion.ServicePack + ", Full: " + osVersion.VersionString); switch (VersionCode.OSBits()) { case VersionCode.Bitness.Bits32: TL.LogMessage("Versions", "Operating system is 32bit"); break; case VersionCode.Bitness.Bits64: TL.LogMessage("Versions", "Operating system is 64bit"); break; default: TL.LogMessage("Versions", "Operating system is unknown bits, PTR length is: " + Conversions.ToString(IntPtr.Size)); break; } switch (VersionCode.ApplicationBits()) { case VersionCode.Bitness.Bits32: TL.LogMessage("Versions", "Application is 32bit"); break; case VersionCode.Bitness.Bits64: TL.LogMessage("Versions", "Application is 64bit"); break; default: TL.LogMessage("Versions", "Application is unknown bits, PTR length is: " + Conversions.ToString(IntPtr.Size)); break; } TL.LogMessage("Versions", ""); TL.LogMessage("Versions", "CLR version: " + Environment.Version.ToString()); string userDomainName = Environment.UserDomainName; string userName = Environment.UserName; string machineName = Environment.MachineName; int processorCount = Environment.ProcessorCount; string systemDirectory = Environment.SystemDirectory; long workingSet = Environment.WorkingSet; TL.LogMessage("Versions", "Machine name: " + machineName + " UserName: "******" DomainName: " + userDomainName); TL.LogMessage("Versions", "Number of processors: " + Conversions.ToString(processorCount) + " System directory: " + systemDirectory + " Working set size: " + Conversions.ToString(workingSet) + " bytes"); TL.LogMessage("Versions", ""); TL.LogMessage("Versions", "My Documents: " + Environment.GetFolderPath(Environment.SpecialFolder.Personal)); TL.LogMessage("Versions", "Application Data: " + Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)); TL.LogMessage("Versions", "Common Application Data: " + Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)); TL.LogMessage("Versions", "Program Files: " + Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)); TL.LogMessage("Versions", "Common Files: " + Environment.GetFolderPath(Environment.SpecialFolder.CommonProgramFiles)); TL.LogMessage("Versions", "System: " + Environment.GetFolderPath(Environment.SpecialFolder.System)); TL.LogMessage("Versions", "Current: " + Environment.CurrentDirectory); TL.LogMessage("Versions", ""); Assembly[] assemblies = currentDomain.GetAssemblies(); int index = 0; while (index < assemblies.Length) { Assembly assembly = assemblies[index]; TL.LogMessage("Versions", "Loaded Assemblies: " + assembly.GetName().Name + " " + assembly.GetName().Version.ToString()); checked { ++index; } } TL.LogMessage("Versions", ""); VersionCode.AssemblyInfo(TL, "Entry Assembly", Assembly.GetEntryAssembly()); VersionCode.AssemblyInfo(TL, "Executing Assembly", Assembly.GetExecutingAssembly()); TL.BlankLine(); } catch (Exception ex) { //ProjectData.SetProjectError(ex); Exception exception = ex; TL.LogMessageCrLf("Versions", "Unexpected exception: " + exception.ToString()); //ProjectData.ClearProjectError(); } }
internal static string ConditionPlatformVersion(string PlatformVersion, IAscomDataStore Profile, TraceLogger TL) { string str = PlatformVersion; if (Profile != null) { try { string withoutExtension = Path.GetFileNameWithoutExtension(Process.GetCurrentProcess().MainModule.FileName); TL?.LogMessage("ConditionPlatformVersion", " ModuleFileName: \"" + withoutExtension + "\" \"" + Process.GetCurrentProcess().MainModule.FileName + "\""); //if (Operators.CompareString(Strings.Left(withoutExtension.ToUpper(), 3), "IS-", false) == 0) if (withoutExtension.ToUpper().StartsWith("IS-")) { TL?.LogMessage("ConditionPlatformVersion", " Inno installer temporary executable detected, searching for parent process!"); TL?.LogMessage("ConditionPlatformVersion", " Old Module Filename: " + withoutExtension); PerformanceCounter performanceCounter = new PerformanceCounter("Process", "Creating Process ID", Process.GetCurrentProcess().ProcessName); withoutExtension = Path.GetFileNameWithoutExtension(Process.GetProcessById(checked ((int)Math.Round((double)performanceCounter.NextValue()))).MainModule.FileName); TL?.LogMessage("ConditionPlatformVersion", " New Module Filename: " + withoutExtension); performanceCounter.Close(); performanceCounter.Dispose(); } SortedList <string, string> sortedList1 = Profile.EnumProfile("ForcePlatformVersion"); IEnumerator <System.Collections.Generic.KeyValuePair <string, string> > enumerator1 = null; try { enumerator1 = sortedList1.GetEnumerator(); while (enumerator1.MoveNext()) { System.Collections.Generic.KeyValuePair <string, string> current = enumerator1.Current; TL?.LogMessage("ConditionPlatformVersion", " ForcedFileName: \"" + current.Key + "\" \"" + current.Value + "\" \"" + Strings.UCase(Path.GetFileNameWithoutExtension(current.Key)) + "\" \"" + Strings.UCase(Path.GetFileName(current.Key)) + "\" \"" + Strings.UCase(current.Key) + "\" \"" + current.Key + "\" \"" + Strings.UCase(withoutExtension) + "\""); string Left = !current.Key.Contains(".") ? current.Key : Path.GetFileNameWithoutExtension(current.Key); if (Operators.CompareString(Left, "", false) != 0 && Strings.UCase(withoutExtension).StartsWith(Strings.UCase(Left))) { str = current.Value; TL?.LogMessage("ConditionPlatformVersion", " Matched file: \"" + withoutExtension + "\" \"" + Left + "\""); } } } finally { if (enumerator1 != null) { enumerator1.Dispose(); } } SortedList <string, string> sortedList2 = Profile.EnumProfile("ForcePlatformVersionSeparator"); IEnumerator <System.Collections.Generic.KeyValuePair <string, string> > enumerator2 = null; try { enumerator2 = sortedList2.GetEnumerator(); while (enumerator2.MoveNext()) { System.Collections.Generic.KeyValuePair <string, string> current = enumerator2.Current; TL?.LogMessage("ConditionPlatformVersion", " ForcedFileName: \"" + current.Key + "\" \"" + current.Value + "\" \"" + Strings.UCase(Path.GetFileNameWithoutExtension(current.Key)) + "\" \"" + Strings.UCase(Path.GetFileName(current.Key)) + "\" \"" + Strings.UCase(current.Key) + "\" \"" + current.Key + "\" \"" + Strings.UCase(withoutExtension) + "\""); if (!current.Key.Contains(".")) { } if (Operators.CompareString(Strings.UCase(Path.GetFileNameWithoutExtension(current.Key)), Strings.UCase(withoutExtension), false) == 0) { if (string.IsNullOrEmpty(current.Value)) { str = str.Replace(".", CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator); TL?.LogMessage("ConditionPlatformVersion", " String IsNullOrEmpty: \"" + str + "\""); } else { str = str.Replace(".", current.Value); TL?.LogMessage("ConditionPlatformVersion", " String Is: \"" + current.Value + "\" \"" + str + "\""); } TL?.LogMessage("ConditionPlatformVersion", " Matched file: \"" + withoutExtension + "\" \"" + current.Key + "\""); } } } finally { if (enumerator2 != null) { enumerator2.Dispose(); } } } catch (Exception ex) { //ProjectData.SetProjectError(ex); Exception exception = ex; TL?.LogMessageCrLf("ConditionPlatformVersion", "Exception: " + exception.ToString()); EventLogCode.LogEvent("ConditionPlatformVersion", "Exception: ", EventLogEntryType.Error, GlobalConstants.EventLogErrors.VB6HelperProfileException, exception.ToString()); //ProjectData.ClearProjectError(); } } TL?.LogMessage("ConditionPlatformVersion", " Returning: \"" + str + "\""); return(str); }