119 lines
4.1 KiB
C#
119 lines
4.1 KiB
C#
using Microsoft.VisualBasic.Devices;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace GFATask
|
|
{
|
|
public class InfoClass
|
|
{
|
|
/// <summary>
|
|
/// Gibt den Titel des Programm-Assembly aus den Projekteigenschaften aus
|
|
/// </summary>
|
|
public static string ProgramName
|
|
{
|
|
get => ((AssemblyTitleAttribute)Attribute.GetCustomAttribute(Assembly.GetExecutingAssembly(), typeof(AssemblyTitleAttribute), false))?.Title;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Gibt den Codenamen des Programm-Assembly aus den Projekteigenschaften aus
|
|
/// </summary>
|
|
public static string ProgramCodeName
|
|
{
|
|
get => Application.ProductName;
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Gibt den Codenamen des Programm-Assembly aus den Projekteigenschaften aus
|
|
/// </summary>
|
|
public static string Copyright
|
|
{
|
|
get => $"{((AssemblyCopyrightAttribute)Assembly.GetExecutingAssembly().GetCustomAttribute(typeof(AssemblyCopyrightAttribute))).Copyright} {DateTime.Now.Year}";
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Gibt eine benutzerdefinierte Version anhand der AssemblyInfo.cs aus
|
|
/// </summary>
|
|
public static string ProgramVersion
|
|
{
|
|
get
|
|
{
|
|
Version version = Assembly.GetExecutingAssembly().GetName().Version;
|
|
return string.Format("{0}.{1}.{2}", version.Major, version.Build.ToString()[0], version.Build.ToString()[1]);
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Gibt die IP-Adresse des Computers als Zeichenkette aus
|
|
/// </summary>
|
|
public static string IPAdress
|
|
{
|
|
get
|
|
{
|
|
string ipadress = System.Net.Dns.GetHostEntry(System.Net.Dns.GetHostName()).AddressList.First(ip => ip.AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork).ToString();
|
|
return $"{ipadress}";
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Gibt Informationen wie den Computernamen, oder den Typen des Computers aus über den genutzten Computer aus
|
|
/// </summary>
|
|
public static string Computer
|
|
{
|
|
get
|
|
{
|
|
bool ica = (Environment.GetEnvironmentVariable("SessionName") ?? "").ToUpper().StartsWith("ICA");
|
|
return $"{SystemInformation.ComputerName} {(ica ? "[Terminalserver]" : "")}";
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Formattierter Programm-Name und -Version als Zeichenkette
|
|
/// </summary>
|
|
public static string Program { get => $"{ProgramName} {ProgramVersion}"; }
|
|
|
|
|
|
/// <summary>
|
|
/// Gibt die aktuell genutzte Windows-Version als Zeichenkette aus
|
|
/// </summary>
|
|
public static string OperatingSystem
|
|
{
|
|
get
|
|
{
|
|
//string win_name = new ComputerInfo().OSFullName;
|
|
|
|
//string reg_win_version = Microsoft.Win32.Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\", "DisplayVersion", "").ToString();
|
|
//string reg_win_installtype = Microsoft.Win32.Registry.GetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\", "InstallationType", "").ToString();
|
|
//return $"{win_name} {reg_win_version} [{reg_win_installtype}]";
|
|
|
|
var os = new System.Management.WMI.OSStructure();
|
|
|
|
return $"{os.Name} {os.ServicePackDisplayName} [{os.InstallType}]\nVersion {os.Version}";
|
|
}
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// Gibt die aktuell genutzte Windows-Version als Zeichenkette aus
|
|
/// </summary>
|
|
public static string Browsers
|
|
{
|
|
get
|
|
{
|
|
return $"{string.Join("\n", XObjects.WebBrowsers.Select(browser => $"{browser.Name} [{browser.Version}]"))}";
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|