Exemple #1
0
        public static void GetWindowsBuildandRevision(WindowsVersionInfo wvi)
        {
            const string keyName = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion";

            //get the 64-bit view first - if you read the 32 bit keys on a 64 bit machine you don't get the revision
            RegistryKey rk = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry64);

            rk = rk.OpenSubKey(keyName);

            // 64bit registry didn't open, open the 32bit registry
            if (rk == null)
            {
                //we couldn't find the value in the 64-bit view so grab the 32-bit view
                rk = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry32);
                rk = rk.OpenSubKey(keyName);
            }

            if (rk != null)
            {
                wvi.branch = (string)rk.GetValue("BuildBranch");
                // all these converts suck
                wvi.build    = Convert.ToUInt32(rk.GetValue("CurrentBuild").ToString());
                wvi.revision = Convert.ToUInt32(rk.GetValue("UBR").ToString());
            }
            rk.Close();
        }
Exemple #2
0
    public AboutForm(ColorTheme colorTheme)
    {
        var assembly           = Assembly.GetEntryAssembly();
        var path               = assembly.Location;
        var lastWriteTime      = File.GetLastWriteTime(path);
        var windowsVersionInfo = WindowsVersionInfo.Get();

        var brightness = colorTheme?.BackColor.GetBrightness();

        var bodyStyle = brightness < 0.12f
            ? "body {background-color: #202020;color:#dcdcdc}"
            : null;

        var text =
            $@"
<style>
    {bodyStyle}
    a {{text-decoration:none}}
</style>
<div style=""font-family:verdana;font-size:9pt"">
Build date: {lastWriteTime.ToString("yyyy-MM-dd")}
<br/><br/>
Version: {assembly.GetName().Version}
<br/><br/>
Copyright © 2002-2022 <a href=""mailto://[email protected]"">Csaba Bernáth</a>
<br/>
This program is freeware and released under the <a href=""https://www.gnu.org/licenses/gpl.txt"">GNU General Public Licence</a>.
<br/><br/>
<a href=""https://github.com/csbernath/DataCommander"">GitHub repository</a>
<br/><br/>
Including <a href=""https://github.com/csbernath/DataCommander/blob/master/Foundation/.Net-6.0/README.md"">Foundation (.NET 6.0) Class Library</a>
<br/><br/>
<a href=""applicationdatafile://"">Application Data file</a>
<br/>
<a href=""logfile://"">Log file</a>
<br/><br/>
<table style=""font-family:verdana;font-size:9pt"">
<tr><td>Windows ProductName:</td><td>{windowsVersionInfo.ProductName}</td></tr>
<tr><td>Windows DisplayVersion:</td><td>{windowsVersionInfo.DisplayVersion}</td></tr>
<tr><td>.NET CLR version:</td><td>{Environment.Version}</td></tr>
</table>
<br/>
Credits:
<ul style=""list-style-type:none"">
    <li><a href=""https://www.jetbrains.com/rider/"">JetBrains Rider 2021.3.3</a></li>
    <li><a href=""https://www.visualstudio.com/vs/community/"">Visual Studio Community 2022</a></li>
    <li><a href=""https://www.jetbrains.com/resharper/"">JetBrains R# ReSharper</a></li>
    <li><a href=""https://github.com/JanKallman/EPPlus"">EPPlus Excel generator</a></li>
    <li><a href=""https://system.data.sqlite.org"">SQLite provider</a></li>
    <li><a href=""https://www.nuget.org/packages/MySql.Data/"">MySQL provider</a></li>
    <li><a href=""https://github.com/npgsql/npgsql"">PostgreSQL provider</a></li>  
</ul>
</div>";

        InitializeComponent();

        webBrowser1.DocumentText = text;
    }
Exemple #3
0
    public static string GetEnvironmentInfo()
    {
        var tickCount          = Environment.TickCount;
        var totalDays          = (double)tickCount / DateTimeConstants.MillisecondsPerDay;
        var workingSet         = Environment.WorkingSet;
        var windowsVersionInfo = WindowsVersionInfo.Get();
        var stopwatchFrequency = GetStopwatchFrequency();
        var zeroDateTime       = LocalTime.Default.Now.AddDays(-totalDays);
        var tickCountString    = $"{tickCount} ({totalDays:N2} days(s) from {zeroDateTime:yyyy.MM.dd HH:mm:ss})";

        var message = $@"Environment information
MachineName:            {Environment.MachineName}
ProcessorCount:         {Environment.ProcessorCount}
OSVersion:              {Environment.OSVersion}
Windows ProductName:    {windowsVersionInfo.ProductName}
Windows DisplayVersion: {windowsVersionInfo.DisplayVersion}
Windows ReleaseId:      {windowsVersionInfo.ReleaseId}
Windows CurrentBuild:   {windowsVersionInfo.CurrentBuild}
Is64BitOperatingSystem: {Environment.Is64BitOperatingSystem}
Is64BitProcess:         {Environment.Is64BitProcess}
IntPtr.Size:            {IntPtr.Size} ({IntPtr.Size * 8} bit)
CLR version:            {Environment.Version}
UserDomainName:         {Environment.UserDomainName}
UserName:               {Environment.UserName}
UserInteractive:        {Environment.UserInteractive}
CurrentDirectory:       {Environment.CurrentDirectory}
CommandLine:            {Environment.CommandLine},
GC IsServerGC:          {GCSettings.IsServerGC}
GC LargeObjectHeapCompactionMode: {GCSettings.LargeObjectHeapCompactionMode}
GC LatencyMode:         {GCSettings.LatencyMode}
WorkingSet:             {(double)workingSet / (1024 * 1024):N} MB ({workingSet} bytes)
TickCount:              {tickCountString}
Stopwatch.Frequency:    {stopwatchFrequency}
TimeZoneInfo.Local.Id:  {TimeZoneInfo.Local.Id}
TempPath:               {Path.GetTempPath()}";

        return(message);
    }
Exemple #4
0
        public AboutForm()
        {
            var assembly               = Assembly.GetEntryAssembly();
            var path                   = assembly.Location;
            var lastWriteTime          = File.GetLastWriteTime(path);
            var dotNetFrameworkRelease = AppDomainMonitor.GetDotNetFrameworkRelease();

            DotNetFrameworkVersionStore.TryGet(dotNetFrameworkRelease, out var dotNetFrameworkVersion);
            var targetFrameworkAttribute = assembly.GetCustomAttribute <TargetFrameworkAttribute>();
            var windowsVersionInfo       = WindowsVersionInfo.Get();

            var text =
                $@"
<style>
    a {{text-decoration:none}}
</style>
<div style=""font-family:verdana;font-size:9pt"">
<a href=""https://github.com/csbernath/DataCommander"">Data Commander</a>
<br/>
<br/>
Including <a href=""https://github.com/csbernath/DataCommander/blob/master/Foundation/.NetStandard-2.0/README.md"">Foundation (.NET Standard 2.0) Class Library</a>
<br/>
<br/>
Version: {assembly.GetName().Version}
<br/>
<br/>
Build date: {lastWriteTime.ToString("yyyy-MM-dd")}
<br/>
<br/>
Copyright © 2002-2019 <a href=""mailto://[email protected]"">Csaba Bernáth</a>
<br/>
This program is freeware and released under the <a href=""https://www.gnu.org/licenses/gpl.txt"">GNU General Public Licence</a>.
<br/>
<br/>
Target Framework: {targetFrameworkAttribute.FrameworkDisplayName}
<br/>
<br/>
<a href=""applicationdatafile://"">Application Data file</a>
<br/>
<a href=""logfile://"">Log file</a>
<br/>
<br/>
<table style=""font-family:verdana;font-size:9pt"">
<tr><td>Windows ProductName:</td><td>{windowsVersionInfo.ProductName}</td></tr>
<tr><td>Windows ReleaseId:</td><td>{windowsVersionInfo.ReleaseId}</td></tr>
<tr><td>Windows CurrentBuild:</td><td>{windowsVersionInfo.CurrentBuild}</td></tr>
<tr><td>.NET CLR version:</td><td>{Environment.Version}</td></tr>
<tr><td>.NET Framework release:</td><td>{dotNetFrameworkRelease}</td></tr>
<tr><td>.NET Framework version:</td><td>{dotNetFrameworkVersion}</td></tr>
<tr><td>.NET Processor architecture:</td><td>{assembly.GetName().ProcessorArchitecture}</td></tr>
</table>
</br>
Credits:
</br>
<ul style=""list-style-type:none"">
    <li><a href=""https://www.visualstudio.com/vs/community/"">Visual Studio Community 2019</a></li>
    <li><a href=""https://www.jetbrains.com/resharper/"">JetBrains R# ReSharper</a></li>
    <li><a href=""https://github.com/JanKallman/EPPlus"">EPPlus Excel generator</a></li>
    <li><a href=""https://system.data.sqlite.org"">SQLite provider</a></li>
    <li><a href=""https://www.nuget.org/packages/MySql.Data/"">MySQL provider</a></li>
    <li><a href=""http://npgsql.projects.pgfoundry.org/"">PostgreSQL provider</a></li>  
</ul>
</div>";

            InitializeComponent();

            webBrowser1.DocumentText = text;
        }
Exemple #5
0
        public static void GetWindowsBuildandRevision(WindowsVersionInfo wvi)
        {
            const string keyName = "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion";

            //get the 64-bit view first - if you read the 32 bit keys on a 64 bit machine you don't get the revision
            RegistryKey rk = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry64);
            rk = rk.OpenSubKey(keyName);

            // 64bit registry didn't open, open the 32bit registry
            if (rk == null)
            {
                //we couldn't find the value in the 64-bit view so grab the 32-bit view
                rk = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry32);
                rk = rk.OpenSubKey(keyName);
            }

            if (rk != null)
            {
                wvi.branch = (string)rk.GetValue("BuildBranch");
                // all these converts suck
                wvi.build = Convert.ToUInt32(rk.GetValue("CurrentBuild").ToString());
                wvi.revision = Convert.ToUInt32(rk.GetValue("UBR").ToString());
            }
            rk.Close();
        }