mirror of
https://github.com/greenshot/greenshot
synced 2025-08-22 22:34:27 -07:00
Updated dependencies, and added initial logic with code smell to give information about the single-exe.
This commit is contained in:
parent
1fee3bd785
commit
0904398749
22 changed files with 608 additions and 420 deletions
|
@ -21,9 +21,9 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AutoProperties.Fody" Version="1.21.0" />
|
<PackageReference Include="AutoProperties.Fody" Version="1.21.0" />
|
||||||
<PackageReference Include="Dapplo.CaliburnMicro.Configuration" Version="1.2.25" />
|
<PackageReference Include="Dapplo.CaliburnMicro.Configuration" Version="1.2.26" />
|
||||||
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.25" />
|
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.26" />
|
||||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.27" />
|
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.28" />
|
||||||
<PackageReference Include="CliWrap" Version="2.2.1" />
|
<PackageReference Include="CliWrap" Version="2.2.1" />
|
||||||
<PackageReference Include="Fody" Version="4.2.1">
|
<PackageReference Include="Fody" Version="4.2.1">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Dapplo.Windows">
|
<PackageReference Include="Dapplo.Windows">
|
||||||
<Version>0.8.27</Version>
|
<Version>0.8.28</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Dapplo.Windows.Com">
|
<PackageReference Include="Dapplo.Windows.Com">
|
||||||
<Version>0.8.27</Version>
|
<Version>0.8.28</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Unofficial.Microsoft.mshtml" Version="7.0.3300" />
|
<PackageReference Include="Unofficial.Microsoft.mshtml" Version="7.0.3300" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
|
@ -112,11 +112,11 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AutoProperties.Fody" Version="1.21.0" />
|
<PackageReference Include="AutoProperties.Fody" Version="1.21.0" />
|
||||||
<PackageReference Include="CommonServiceLocator" Version="2.0.4" />
|
<PackageReference Include="CommonServiceLocator" Version="2.0.4" />
|
||||||
<PackageReference Include="Dapplo.CaliburnMicro.Configuration" Version="1.2.25" />
|
<PackageReference Include="Dapplo.CaliburnMicro.Configuration" Version="1.2.26" />
|
||||||
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.25" />
|
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.26" />
|
||||||
<PackageReference Include="Dapplo.HttpExtensions" Version="0.9.18" />
|
<PackageReference Include="Dapplo.HttpExtensions" Version="0.9.18" />
|
||||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.27" />
|
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.28" />
|
||||||
<PackageReference Include="Dapplo.Windows.Icons" Version="0.8.27" />
|
<PackageReference Include="Dapplo.Windows.Icons" Version="0.8.28" />
|
||||||
<PackageReference Include="Fody" Version="4.2.1">
|
<PackageReference Include="Fody" Version="4.2.1">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
|
|
|
@ -20,9 +20,9 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AutoProperties.Fody" Version="1.21.0" />
|
<PackageReference Include="AutoProperties.Fody" Version="1.21.0" />
|
||||||
<PackageReference Include="Dapplo.CaliburnMicro.Configuration" Version="1.2.25" />
|
<PackageReference Include="Dapplo.CaliburnMicro.Configuration" Version="1.2.26" />
|
||||||
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.25" />
|
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.26" />
|
||||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.27" />
|
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.28" />
|
||||||
<PackageReference Include="Interop.Microsoft.Office.Interop.OneNote" Version="1.1.0" />
|
<PackageReference Include="Interop.Microsoft.Office.Interop.OneNote" Version="1.1.0" />
|
||||||
<PackageReference Include="Microsoft.Office.Interop.Excel" Version="15.0.4795.1000" />
|
<PackageReference Include="Microsoft.Office.Interop.Excel" Version="15.0.4795.1000" />
|
||||||
<PackageReference Include="Microsoft.Office.Interop.Outlook" Version="15.0.4797.1003" />
|
<PackageReference Include="Microsoft.Office.Interop.Outlook" Version="15.0.4797.1003" />
|
||||||
|
|
|
@ -19,9 +19,9 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Dapplo.CaliburnMicro.Configuration" Version="1.2.25" />
|
<PackageReference Include="Dapplo.CaliburnMicro.Configuration" Version="1.2.26" />
|
||||||
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.25" />
|
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.26" />
|
||||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.27" />
|
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.28" />
|
||||||
<PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.18362.2002-preview" />
|
<PackageReference Include="Microsoft.Windows.SDK.Contracts" Version="10.0.18362.2002-preview" />
|
||||||
<PackageReference Include="System.Runtime.WindowsRuntime" Version="4.6.0-preview4.19212.13" />
|
<PackageReference Include="System.Runtime.WindowsRuntime" Version="4.6.0-preview4.19212.13" />
|
||||||
<PackageReference Include="Microsoft.Toolkit.Forms.UI.Controls" Version="6.0.0-preview4.1" />
|
<PackageReference Include="Microsoft.Toolkit.Forms.UI.Controls" Version="6.0.0-preview4.1" />
|
||||||
|
|
|
@ -40,12 +40,19 @@ namespace Greenshot.Addons.Core
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Check if path is a directory
|
// Check if path is a directory
|
||||||
if (Directory.Exists(path))
|
if (Directory.Exists(path))
|
||||||
{
|
{
|
||||||
using (Process.Start(path))
|
var processStartInfo = new ProcessStartInfo(path)
|
||||||
|
{
|
||||||
|
CreateNoWindow = true,
|
||||||
|
UseShellExecute = true
|
||||||
|
};
|
||||||
|
using (Process.Start(processStartInfo))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -53,8 +60,14 @@ namespace Greenshot.Addons.Core
|
||||||
// Check if path is a file
|
// Check if path is a file
|
||||||
if (File.Exists(path))
|
if (File.Exists(path))
|
||||||
{
|
{
|
||||||
|
var processStartInfo = new ProcessStartInfo("explorer.exe")
|
||||||
|
{
|
||||||
|
Arguments = $"/select,\"{path}\"",
|
||||||
|
CreateNoWindow = true,
|
||||||
|
UseShellExecute = true
|
||||||
|
};
|
||||||
// Start the explorer process and select the file
|
// Start the explorer process and select the file
|
||||||
using (var explorer = Process.Start("explorer.exe", $"/select,\"{path}\""))
|
using (var explorer = Process.Start(processStartInfo))
|
||||||
{
|
{
|
||||||
explorer?.WaitForInputIdle(500);
|
explorer?.WaitForInputIdle(500);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -638,7 +638,7 @@ namespace Greenshot.Addons.Core
|
||||||
CreateNoWindow = true,
|
CreateNoWindow = true,
|
||||||
RedirectStandardOutput = true,
|
RedirectStandardOutput = true,
|
||||||
RedirectStandardError = true,
|
RedirectStandardError = true,
|
||||||
UseShellExecute = false
|
UseShellExecute = true
|
||||||
};
|
};
|
||||||
using (var process = Process.Start(processStartInfo))
|
using (var process = Process.Start(processStartInfo))
|
||||||
{
|
{
|
||||||
|
|
|
@ -23,13 +23,13 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AutoProperties.Fody" Version="1.21.0" />
|
<PackageReference Include="AutoProperties.Fody" Version="1.21.0" />
|
||||||
<PackageReference Include="Dapplo.CaliburnMicro.Configuration">
|
<PackageReference Include="Dapplo.CaliburnMicro.Configuration">
|
||||||
<Version>1.2.25</Version>
|
<Version>1.2.26</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Dapplo.CaliburnMicro.Toasts">
|
<PackageReference Include="Dapplo.CaliburnMicro.Toasts">
|
||||||
<Version>1.2.25</Version>
|
<Version>1.2.26</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Dapplo.CaliburnMicro.Translations">
|
<PackageReference Include="Dapplo.CaliburnMicro.Translations">
|
||||||
<Version>1.2.25</Version>
|
<Version>1.2.26</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Dapplo.HttpExtensions">
|
<PackageReference Include="Dapplo.HttpExtensions">
|
||||||
<Version>0.9.18</Version>
|
<Version>0.9.18</Version>
|
||||||
|
@ -41,13 +41,13 @@
|
||||||
<Version>0.9.18</Version>
|
<Version>0.9.18</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Dapplo.Windows.Clipboard">
|
<PackageReference Include="Dapplo.Windows.Clipboard">
|
||||||
<Version>0.8.27</Version>
|
<Version>0.8.28</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Dapplo.Windows.Dpi">
|
<PackageReference Include="Dapplo.Windows.Dpi">
|
||||||
<Version>0.8.27</Version>
|
<Version>0.8.28</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Dapplo.Windows.Icons">
|
<PackageReference Include="Dapplo.Windows.Icons">
|
||||||
<Version>0.8.27</Version>
|
<Version>0.8.28</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Fody" Version="4.2.1">
|
<PackageReference Include="Fody" Version="4.2.1">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
|
@ -57,7 +57,7 @@
|
||||||
<Version>3.0.0-alpha0146</Version>
|
<Version>3.0.0-alpha0146</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Svg">
|
<PackageReference Include="Svg">
|
||||||
<Version>2.4.2</Version>
|
<Version>2.4.3</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
@ -126,7 +126,12 @@ namespace Greenshot.Addons.ViewModels
|
||||||
|
|
||||||
if (Information.IsCloudExport)
|
if (Information.IsCloudExport)
|
||||||
{
|
{
|
||||||
Process.Start(Information.Uri);
|
var processStartInfo = new ProcessStartInfo(Information.Uri)
|
||||||
|
{
|
||||||
|
CreateNoWindow = true,
|
||||||
|
UseShellExecute = true
|
||||||
|
};
|
||||||
|
Process.Start(processStartInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Dapplo.Windows.Icons">
|
<PackageReference Include="Dapplo.Windows.Icons">
|
||||||
<Version>0.8.27</Version>
|
<Version>0.8.28</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
@ -9,10 +9,10 @@
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Dapplo.CaliburnMicro.Translations">
|
<PackageReference Include="Dapplo.CaliburnMicro.Translations">
|
||||||
<Version>1.2.25</Version>
|
<Version>1.2.26</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Svg">
|
<PackageReference Include="Svg">
|
||||||
<Version>2.4.2</Version>
|
<Version>2.4.3</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="System.Memory">
|
<PackageReference Include="System.Memory">
|
||||||
<Version>4.5.2</Version>
|
<Version>4.5.2</Version>
|
||||||
|
|
|
@ -43,10 +43,10 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="BenchmarkDotNet" Version="0.11.5" />
|
<PackageReference Include="BenchmarkDotNet" Version="0.11.5" />
|
||||||
<PackageReference Include="CommandLineParser" Version="2.5.0" />
|
<PackageReference Include="CommandLineParser" Version="2.5.0" />
|
||||||
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.25" />
|
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.26" />
|
||||||
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
||||||
<PackageReference Include="Dapplo.Log.XUnit" Version="1.3.11" />
|
<PackageReference Include="Dapplo.Log.XUnit" Version="1.3.11" />
|
||||||
<PackageReference Include="Dapplo.Windows" Version="0.8.27" />
|
<PackageReference Include="Dapplo.Windows" Version="0.8.28" />
|
||||||
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="2.1.0" />
|
<PackageReference Include="Microsoft.DotNet.PlatformAbstractions" Version="2.1.0" />
|
||||||
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta0006" />
|
<PackageReference Include="SixLabors.ImageSharp.Drawing" Version="1.0.0-beta0006" />
|
||||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.1" />
|
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.1" />
|
||||||
|
|
|
@ -73,7 +73,7 @@ namespace Greenshot.Components
|
||||||
if (argument.ToLower().Equals("/help") || argument.ToLower().Equals("/h") || argument.ToLower().Equals("/?"))
|
if (argument.ToLower().Equals("/help") || argument.ToLower().Equals("/h") || argument.ToLower().Equals("/?"))
|
||||||
{
|
{
|
||||||
// Try to attach to the console
|
// Try to attach to the console
|
||||||
var attachedToConsole = Kernel32Api.AttachConsole(Kernel32Api.ATTACHCONSOLE_ATTACHPARENTPROCESS);
|
var attachedToConsole = Kernel32Api.AttachConsole();
|
||||||
// If attach didn't work, open a console
|
// If attach didn't work, open a console
|
||||||
if (!attachedToConsole)
|
if (!attachedToConsole)
|
||||||
{
|
{
|
||||||
|
@ -186,7 +186,7 @@ namespace Greenshot.Components
|
||||||
if (arguments.Length > 0 && arguments[0].ToLower().Equals("/capture"))
|
if (arguments.Length > 0 && arguments[0].ToLower().Equals("/capture"))
|
||||||
{
|
{
|
||||||
// Try to attach to the console
|
// Try to attach to the console
|
||||||
bool attachedToConsole = Kernel32Api.AttachConsole(Kernel32Api.ATTACHCONSOLE_ATTACHPARENTPROCESS);
|
bool attachedToConsole = Kernel32Api.AttachConsole();
|
||||||
// If attach didn't work, open a console
|
// If attach didn't work, open a console
|
||||||
if (!attachedToConsole)
|
if (!attachedToConsole)
|
||||||
{
|
{
|
||||||
|
|
|
@ -158,7 +158,7 @@ namespace Greenshot.Forms
|
||||||
pictureBox1.Size = FormDpiHandler.ScaleWithCurrentDpi(new NativeSize(90,90));
|
pictureBox1.Size = FormDpiHandler.ScaleWithCurrentDpi(new NativeSize(90,90));
|
||||||
});
|
});
|
||||||
|
|
||||||
var versionInfo = $@"Greenshot {versionProvider.CurrentVersion} {(coreConfiguration.IsPortable ? " Portable" : "")} ({OsInfo.Bits} bit)";
|
var versionInfo = $@"Greenshot {versionProvider.CurrentVersion} {(SingleExeHelper.IsRunningAsSingleExe? "SE " : "")}({OsInfo.Bits} bit)";
|
||||||
if (versionProvider.IsUpdateAvailable)
|
if (versionProvider.IsUpdateAvailable)
|
||||||
{
|
{
|
||||||
versionInfo += $" latest is: {versionProvider.LatestVersion}";
|
versionInfo += $" latest is: {versionProvider.LatestVersion}";
|
||||||
|
@ -247,7 +247,12 @@ namespace Greenshot.Forms
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
linkLabel.LinkVisited = true;
|
linkLabel.LinkVisited = true;
|
||||||
Process.Start(linkLabel.Text);
|
var processStartInfo = new ProcessStartInfo(linkLabel.Text)
|
||||||
|
{
|
||||||
|
CreateNoWindow = true,
|
||||||
|
UseShellExecute = true
|
||||||
|
};
|
||||||
|
Process.Start(processStartInfo);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
|
|
@ -57,7 +57,12 @@ namespace Greenshot.Forms
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
link.LinkVisited = true;
|
link.LinkVisited = true;
|
||||||
Process.Start(link.Text);
|
var processStartInfo = new ProcessStartInfo(link.Text)
|
||||||
|
{
|
||||||
|
CreateNoWindow = true,
|
||||||
|
UseShellExecute = true
|
||||||
|
};
|
||||||
|
Process.Start(processStartInfo);
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
|
|
|
@ -801,7 +801,15 @@ namespace Greenshot.Forms
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
private void Contextmenu_donateClick(object sender, EventArgs e)
|
private void Contextmenu_donateClick(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
BeginInvoke((MethodInvoker) delegate { Process.Start("http://getgreenshot.org/support/?version=" + Assembly.GetEntryAssembly().GetName().Version); });
|
BeginInvoke((MethodInvoker) delegate
|
||||||
|
{
|
||||||
|
var processStartInfo = new ProcessStartInfo("http://getgreenshot.org/support/?version=" + Assembly.GetEntryAssembly()?.GetName().Version)
|
||||||
|
{
|
||||||
|
CreateNoWindow = true,
|
||||||
|
UseShellExecute = true
|
||||||
|
};
|
||||||
|
Process.Start(processStartInfo);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -58,25 +58,25 @@
|
||||||
<PackageReference Include="AutoProperties.Fody" Version="1.21.0" />
|
<PackageReference Include="AutoProperties.Fody" Version="1.21.0" />
|
||||||
<PackageReference Include="CommandLineParser" Version="2.5.0" />
|
<PackageReference Include="CommandLineParser" Version="2.5.0" />
|
||||||
<PackageReference Include="CommonServiceLocator" Version="2.0.4" />
|
<PackageReference Include="CommonServiceLocator" Version="2.0.4" />
|
||||||
<PackageReference Include="Dapplo.CaliburnMicro.Dapp" Version="1.2.25" />
|
<PackageReference Include="Dapplo.CaliburnMicro.Dapp" Version="1.2.26" />
|
||||||
<PackageReference Include="Dapplo.CaliburnMicro.Configuration" Version="1.2.25" />
|
<PackageReference Include="Dapplo.CaliburnMicro.Configuration" Version="1.2.26" />
|
||||||
<PackageReference Include="Dapplo.CaliburnMicro.Metro" Version="1.2.25" />
|
<PackageReference Include="Dapplo.CaliburnMicro.Metro" Version="1.2.26" />
|
||||||
<PackageReference Include="Dapplo.CaliburnMicro.Toasts" Version="1.2.25" />
|
<PackageReference Include="Dapplo.CaliburnMicro.Toasts" Version="1.2.26" />
|
||||||
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.25" />
|
<PackageReference Include="Dapplo.CaliburnMicro.Translations" Version="1.2.26" />
|
||||||
<PackageReference Include="Dapplo.HttpExtensions.JsonNet" Version="0.9.18" />
|
<PackageReference Include="Dapplo.HttpExtensions.JsonNet" Version="0.9.18" />
|
||||||
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
<PackageReference Include="Dapplo.HttpExtensions.OAuth" Version="0.9.18" />
|
||||||
<PackageReference Include="Dapplo.Log.LogFile" Version="1.3.11" />
|
<PackageReference Include="Dapplo.Log.LogFile" Version="1.3.11" />
|
||||||
<PackageReference Include="Dapplo.Log.Loggers" Version="1.3.11" />
|
<PackageReference Include="Dapplo.Log.Loggers" Version="1.3.11" />
|
||||||
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.27" />
|
<PackageReference Include="Dapplo.Windows.Clipboard" Version="0.8.28" />
|
||||||
<PackageReference Include="Dapplo.Windows.Icons" Version="0.8.27" />
|
<PackageReference Include="Dapplo.Windows.Icons" Version="0.8.28" />
|
||||||
<PackageReference Include="Dapplo.Windows.Multimedia" Version="0.8.27" />
|
<PackageReference Include="Dapplo.Windows.Multimedia" Version="0.8.28" />
|
||||||
<PackageReference Include="Fody" Version="4.2.1">
|
<PackageReference Include="Fody" Version="4.2.1">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="gong-wpf-dragdrop" Version="2.0.1" />
|
<PackageReference Include="gong-wpf-dragdrop" Version="2.0.1" />
|
||||||
<PackageReference Include="MahApps.Metro.IconPacks" Version="3.0.0-alpha0146" />
|
<PackageReference Include="MahApps.Metro.IconPacks" Version="3.0.0-alpha0146" />
|
||||||
<PackageReference Include="Svg" Version="2.4.2" />
|
<PackageReference Include="Svg" Version="2.4.3" />
|
||||||
<PackageReference Include="System.Runtime" Version="4.3.1" />
|
<PackageReference Include="System.Runtime" Version="4.3.1" />
|
||||||
<PackageReference Include="System.Runtime.Extensions" Version="4.3.1" />
|
<PackageReference Include="System.Runtime.Extensions" Version="4.3.1" />
|
||||||
<PackageReference Include="System.Runtime.WindowsRuntime" Version="4.6.0-preview4.19212.13" />
|
<PackageReference Include="System.Runtime.WindowsRuntime" Version="4.6.0-preview4.19212.13" />
|
||||||
|
|
|
@ -36,7 +36,12 @@ namespace Greenshot.Help
|
||||||
public static void LoadHelp()
|
public static void LoadHelp()
|
||||||
{
|
{
|
||||||
var uri = FindOnlineHelpUrl("en-US");// Language.CurrentLanguage);// ?? Language.HelpFilePath;
|
var uri = FindOnlineHelpUrl("en-US");// Language.CurrentLanguage);// ?? Language.HelpFilePath;
|
||||||
Process.Start(uri);
|
var processStartInfo = new ProcessStartInfo(uri)
|
||||||
|
{
|
||||||
|
CreateNoWindow = true,
|
||||||
|
UseShellExecute = true
|
||||||
|
};
|
||||||
|
Process.Start(processStartInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <returns>
|
/// <returns>
|
||||||
|
|
|
@ -18,15 +18,10 @@
|
||||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using Dapplo.Windows.Kernel32;
|
|
||||||
using Dapplo.Windows.Kernel32.Enums;
|
|
||||||
using Dapplo.Windows.Kernel32.Structs;
|
|
||||||
using Dapplo.Windows.User32;
|
using Dapplo.Windows.User32;
|
||||||
|
|
||||||
namespace Greenshot.Helpers
|
namespace Greenshot.Helpers
|
||||||
|
@ -72,6 +67,10 @@ namespace Greenshot.Helpers
|
||||||
public static string EnvironmentToString(bool newline)
|
public static string EnvironmentToString(bool newline)
|
||||||
{
|
{
|
||||||
var environment = new StringBuilder("Software version: " + Application.ProductVersion);
|
var environment = new StringBuilder("Software version: " + Application.ProductVersion);
|
||||||
|
if (SingleExeHelper.IsRunningAsSingleExe)
|
||||||
|
{
|
||||||
|
environment.Append(" SE");
|
||||||
|
}
|
||||||
environment.Append(" (" + OsInfo.Bits + " bit)");
|
environment.Append(" (" + OsInfo.Bits + " bit)");
|
||||||
|
|
||||||
if (newline)
|
if (newline)
|
||||||
|
@ -118,7 +117,9 @@ namespace Greenshot.Helpers
|
||||||
environment.Append(", ");
|
environment.Append(", ");
|
||||||
}
|
}
|
||||||
|
|
||||||
environment.AppendFormat("Location: {0}", Assembly.GetEntryAssembly()?.Location);
|
if (SingleExeHelper.IsRunningAsSingleExe)
|
||||||
|
{
|
||||||
|
environment.AppendFormat("Exe Location: {0}", SingleExeHelper.SingleExeLocation);
|
||||||
if (newline)
|
if (newline)
|
||||||
{
|
{
|
||||||
environment.AppendLine();
|
environment.AppendLine();
|
||||||
|
@ -127,6 +128,29 @@ namespace Greenshot.Helpers
|
||||||
{
|
{
|
||||||
environment.Append(", ");
|
environment.Append(", ");
|
||||||
}
|
}
|
||||||
|
environment.AppendFormat("Unpacked into: {0}", SingleExeHelper.UnpackPath);
|
||||||
|
if (newline)
|
||||||
|
{
|
||||||
|
environment.AppendLine();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
environment.Append(", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
environment.AppendFormat("Exe Location: {0}", Assembly.GetEntryAssembly()?.Location);
|
||||||
|
if (newline)
|
||||||
|
{
|
||||||
|
environment.AppendLine();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
environment.Append(", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Get some important information for fixing GDI related Problems
|
// Get some important information for fixing GDI related Problems
|
||||||
environment.AppendFormat("GDI object count: {0}", User32Api.GetGuiResourcesGdiCount());
|
environment.AppendFormat("GDI object count: {0}", User32Api.GetGuiResourcesGdiCount());
|
||||||
|
@ -223,366 +247,4 @@ namespace Greenshot.Helpers
|
||||||
return exceptionText.ToString();
|
return exceptionText.ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Provides detailed information about the host operating system.
|
|
||||||
/// Code is available at: http://www.csharp411.com/determine-windows-version-and-edition-with-c/
|
|
||||||
/// </summary>
|
|
||||||
public static class OsInfo
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// Determines if the current application is 32 or 64-bit.
|
|
||||||
/// </summary>
|
|
||||||
public static int Bits => IntPtr.Size * 8;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the service pack information of the operating system running on this computer.
|
|
||||||
/// </summary>
|
|
||||||
public static string ServicePack
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
var servicePack = string.Empty;
|
|
||||||
var osVersionInfo = OsVersionInfoEx.Create();
|
|
||||||
|
|
||||||
if (Kernel32Api.GetVersionEx(ref osVersionInfo))
|
|
||||||
{
|
|
||||||
servicePack = osVersionInfo.ServicePackVersion;
|
|
||||||
}
|
|
||||||
|
|
||||||
return servicePack;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string _sEdition;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the edition of the operating system running on this computer.
|
|
||||||
/// </summary>
|
|
||||||
public static string Edition
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_sEdition != null)
|
|
||||||
{
|
|
||||||
return _sEdition; //***** RETURN *****//
|
|
||||||
}
|
|
||||||
|
|
||||||
var edition = string.Empty;
|
|
||||||
|
|
||||||
var osVersion = Environment.OSVersion;
|
|
||||||
var osVersionInfo = OsVersionInfoEx.Create();
|
|
||||||
if (!Kernel32Api.GetVersionEx(ref osVersionInfo))
|
|
||||||
{
|
|
||||||
_sEdition = edition;
|
|
||||||
return edition;
|
|
||||||
}
|
|
||||||
|
|
||||||
var majorVersion = osVersion.Version.Major;
|
|
||||||
var minorVersion = osVersion.Version.Minor;
|
|
||||||
var productType = osVersionInfo.ProductType;
|
|
||||||
var suiteMask = osVersionInfo.SuiteMask;
|
|
||||||
|
|
||||||
if (majorVersion == 4)
|
|
||||||
{
|
|
||||||
if (productType.HasFlag(WindowsProductTypes.VER_NT_WORKSTATION))
|
|
||||||
{
|
|
||||||
// Windows NT 4.0 Workstation
|
|
||||||
edition = "Workstation";
|
|
||||||
}
|
|
||||||
else if (productType.HasFlag(WindowsProductTypes.VER_NT_SERVER))
|
|
||||||
{
|
|
||||||
edition = suiteMask.HasFlag(WindowsSuites.Enterprise) ? "Enterprise Server" : "Standard Server";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (majorVersion == 5)
|
|
||||||
{
|
|
||||||
if (productType.HasFlag(WindowsProductTypes.VER_NT_WORKSTATION))
|
|
||||||
{
|
|
||||||
if (suiteMask.HasFlag(WindowsSuites.Personal))
|
|
||||||
{
|
|
||||||
// Windows XP Home Edition
|
|
||||||
edition = "Home";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Windows XP / Windows 2000 Professional
|
|
||||||
edition = "Professional";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (productType.HasFlag(WindowsProductTypes.VER_NT_SERVER))
|
|
||||||
{
|
|
||||||
if (minorVersion == 0)
|
|
||||||
{
|
|
||||||
if (suiteMask.HasFlag(WindowsSuites.DataCenter))
|
|
||||||
{
|
|
||||||
// Windows 2000 Datacenter Server
|
|
||||||
edition = "Datacenter Server";
|
|
||||||
}
|
|
||||||
else if (suiteMask.HasFlag(WindowsSuites.Enterprise))
|
|
||||||
{
|
|
||||||
// Windows 2000 Advanced Server
|
|
||||||
edition = "Advanced Server";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Windows 2000 Server
|
|
||||||
edition = "Server";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (suiteMask.HasFlag(WindowsSuites.DataCenter))
|
|
||||||
{
|
|
||||||
// Windows Server 2003 Datacenter Edition
|
|
||||||
edition = "Datacenter";
|
|
||||||
}
|
|
||||||
else if (suiteMask.HasFlag(WindowsSuites.Enterprise))
|
|
||||||
{
|
|
||||||
// Windows Server 2003 Enterprise Edition
|
|
||||||
edition = "Enterprise";
|
|
||||||
}
|
|
||||||
else if (suiteMask.HasFlag(WindowsSuites.Blade))
|
|
||||||
{
|
|
||||||
// Windows Server 2003 Web Edition
|
|
||||||
edition = "Web Edition";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Windows Server 2003 Standard Edition
|
|
||||||
edition = "Standard";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
else if (majorVersion == 6)
|
|
||||||
{
|
|
||||||
if (Kernel32Api.GetProductInfo(majorVersion, minorVersion, osVersionInfo.ServicePackMajor, osVersionInfo.ServicePackMinor, out var ed))
|
|
||||||
{
|
|
||||||
var memberInfo = ed.GetType().GetMember(ed.ToString()).FirstOrDefault();
|
|
||||||
|
|
||||||
if (memberInfo != null)
|
|
||||||
{
|
|
||||||
var descriptionAttribute = (DescriptionAttribute) memberInfo.GetCustomAttributes(typeof(DescriptionAttribute), false).FirstOrDefault();
|
|
||||||
edition = descriptionAttribute?.Description ?? "unknown";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
_sEdition = edition;
|
|
||||||
return edition;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string _name;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the name of the operating system running on this computer.
|
|
||||||
/// </summary>
|
|
||||||
public static string Name
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_name != null)
|
|
||||||
{
|
|
||||||
return _name; //***** RETURN *****//
|
|
||||||
}
|
|
||||||
|
|
||||||
var name = "unknown";
|
|
||||||
|
|
||||||
var osVersion = Environment.OSVersion;
|
|
||||||
var osVersionInfo = OsVersionInfoEx.Create();
|
|
||||||
if (!Kernel32Api.GetVersionEx(ref osVersionInfo))
|
|
||||||
{
|
|
||||||
_name = name;
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
var majorVersion = osVersion.Version.Major;
|
|
||||||
var minorVersion = osVersion.Version.Minor;
|
|
||||||
var productType = osVersionInfo.ProductType;
|
|
||||||
var suiteMask = osVersionInfo.SuiteMask;
|
|
||||||
switch (osVersion.Platform)
|
|
||||||
{
|
|
||||||
case PlatformID.Win32Windows:
|
|
||||||
if (majorVersion == 4)
|
|
||||||
{
|
|
||||||
var csdVersion = osVersionInfo.ServicePackVersion;
|
|
||||||
switch (minorVersion)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
if (csdVersion == "B" || csdVersion == "C")
|
|
||||||
{
|
|
||||||
name = "Windows 95 OSR2";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
name = "Windows 95";
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 10:
|
|
||||||
name = csdVersion == "A" ? "Windows 98 Second Edition" : "Windows 98";
|
|
||||||
break;
|
|
||||||
case 90:
|
|
||||||
name = "Windows Me";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case PlatformID.Win32NT:
|
|
||||||
switch (majorVersion)
|
|
||||||
{
|
|
||||||
case 3:
|
|
||||||
name = "Windows NT 3.51";
|
|
||||||
break;
|
|
||||||
case 4:
|
|
||||||
switch (productType)
|
|
||||||
{
|
|
||||||
case WindowsProductTypes.VER_NT_WORKSTATION:
|
|
||||||
name = "Windows NT 4.0";
|
|
||||||
break;
|
|
||||||
case WindowsProductTypes.VER_NT_DOMAIN_CONTROLLER:
|
|
||||||
case WindowsProductTypes.VER_NT_SERVER:
|
|
||||||
name = "Windows NT 4.0 Server";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 5:
|
|
||||||
switch (minorVersion)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
name = "Windows 2000";
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
switch (suiteMask)
|
|
||||||
{
|
|
||||||
case WindowsSuites.Personal:
|
|
||||||
name = "Windows XP Professional";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
name = "Windows XP";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
switch (suiteMask)
|
|
||||||
{
|
|
||||||
case WindowsSuites.Personal:
|
|
||||||
name = "Windows XP Professional x64";
|
|
||||||
break;
|
|
||||||
case WindowsSuites.Enterprise:
|
|
||||||
name = "Windows Server 2003 Enterprise";
|
|
||||||
break;
|
|
||||||
case WindowsSuites.DataCenter:
|
|
||||||
name = "Windows Server 2003 Data Center";
|
|
||||||
break;
|
|
||||||
case WindowsSuites.Blade:
|
|
||||||
name = "Windows Server 2003 Web Edition";
|
|
||||||
break;
|
|
||||||
case WindowsSuites.WHServer:
|
|
||||||
name = "Windows Home Server";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
name = "Windows Server 2003";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 6:
|
|
||||||
switch (minorVersion)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
switch (productType)
|
|
||||||
{
|
|
||||||
case WindowsProductTypes.VER_NT_SERVER:
|
|
||||||
name = "Windows Server 2008";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
name = "Windows Vista";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
switch (productType)
|
|
||||||
{
|
|
||||||
case WindowsProductTypes.VER_NT_SERVER:
|
|
||||||
name = "Windows Server 2008 R2";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
name = "Windows 7";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
name = "Windows 8";
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
name = "Windows 8.1";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 10:
|
|
||||||
name = "Windows 10";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
_name = name;
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the build version number of the operating system running on this computer.
|
|
||||||
/// </summary>
|
|
||||||
public static int BuildVersion => Environment.OSVersion.Version.Build;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the full version string of the operating system running on this computer.
|
|
||||||
/// </summary>
|
|
||||||
public static string VersionString
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
return string.Format("{0}.{1} build {3} revision {2:X}", Environment.OSVersion.Version.Major, Environment.OSVersion.Version.Minor,
|
|
||||||
Environment.OSVersion.Version.Revision, Environment.OSVersion.Version.Build);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the full version of the operating system running on this computer.
|
|
||||||
/// </summary>
|
|
||||||
public static Version Version
|
|
||||||
{
|
|
||||||
get { return Environment.OSVersion.Version; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the major version number of the operating system running on this computer.
|
|
||||||
/// </summary>
|
|
||||||
public static int MajorVersion
|
|
||||||
{
|
|
||||||
get { return Environment.OSVersion.Version.Major; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the minor version number of the operating system running on this computer.
|
|
||||||
/// </summary>
|
|
||||||
public static int MinorVersion
|
|
||||||
{
|
|
||||||
get { return Environment.OSVersion.Version.Minor; }
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Gets the revision version number of the operating system running on this computer.
|
|
||||||
/// </summary>
|
|
||||||
public static int RevisionVersion
|
|
||||||
{
|
|
||||||
get { return Environment.OSVersion.Version.Revision; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
392
src/Greenshot/Helpers/OsInfo.cs
Normal file
392
src/Greenshot/Helpers/OsInfo.cs
Normal file
|
@ -0,0 +1,392 @@
|
||||||
|
// Dapplo - building blocks for desktop applications
|
||||||
|
// Copyright (C) 2019 Dapplo
|
||||||
|
//
|
||||||
|
// For more information see: http://dapplo.net/
|
||||||
|
// Dapplo repositories are hosted on GitHub: https://github.com/dapplo
|
||||||
|
//
|
||||||
|
// This file is part of Greenshot
|
||||||
|
//
|
||||||
|
// Greenshot is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 3 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// Greenshot is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU Lesser General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have a copy of the GNU Lesser General Public License
|
||||||
|
// along with Greenshot. If not, see <http://www.gnu.org/licenses/lgpl.txt>.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using Dapplo.Windows.Kernel32;
|
||||||
|
using Dapplo.Windows.Kernel32.Enums;
|
||||||
|
using Dapplo.Windows.Kernel32.Structs;
|
||||||
|
|
||||||
|
namespace Greenshot.Helpers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides detailed information about the host operating system.
|
||||||
|
/// Code is available at: http://www.csharp411.com/determine-windows-version-and-edition-with-c/
|
||||||
|
/// </summary>
|
||||||
|
public static class OsInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Determines if the current application is 32 or 64-bit.
|
||||||
|
/// </summary>
|
||||||
|
public static int Bits => IntPtr.Size * 8;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the service pack information of the operating system running on this computer.
|
||||||
|
/// </summary>
|
||||||
|
public static string ServicePack
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
var servicePack = string.Empty;
|
||||||
|
var osVersionInfo = OsVersionInfoEx.Create();
|
||||||
|
|
||||||
|
if (Kernel32Api.GetVersionEx(ref osVersionInfo))
|
||||||
|
{
|
||||||
|
servicePack = osVersionInfo.ServicePackVersion;
|
||||||
|
}
|
||||||
|
|
||||||
|
return servicePack;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string _sEdition;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the edition of the operating system running on this computer.
|
||||||
|
/// </summary>
|
||||||
|
public static string Edition
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_sEdition != null)
|
||||||
|
{
|
||||||
|
return _sEdition; //***** RETURN *****//
|
||||||
|
}
|
||||||
|
|
||||||
|
var edition = string.Empty;
|
||||||
|
|
||||||
|
var osVersion = Environment.OSVersion;
|
||||||
|
var osVersionInfo = OsVersionInfoEx.Create();
|
||||||
|
if (!Kernel32Api.GetVersionEx(ref osVersionInfo))
|
||||||
|
{
|
||||||
|
_sEdition = edition;
|
||||||
|
return edition;
|
||||||
|
}
|
||||||
|
|
||||||
|
var majorVersion = osVersion.Version.Major;
|
||||||
|
var minorVersion = osVersion.Version.Minor;
|
||||||
|
var productType = osVersionInfo.ProductType;
|
||||||
|
var suiteMask = osVersionInfo.SuiteMask;
|
||||||
|
|
||||||
|
if (majorVersion == 4)
|
||||||
|
{
|
||||||
|
if (productType.HasFlag(WindowsProductTypes.VER_NT_WORKSTATION))
|
||||||
|
{
|
||||||
|
// Windows NT 4.0 Workstation
|
||||||
|
edition = "Workstation";
|
||||||
|
}
|
||||||
|
else if (productType.HasFlag(WindowsProductTypes.VER_NT_SERVER))
|
||||||
|
{
|
||||||
|
edition = suiteMask.HasFlag(WindowsSuites.Enterprise) ? "Enterprise Server" : "Standard Server";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (majorVersion == 5)
|
||||||
|
{
|
||||||
|
if (productType.HasFlag(WindowsProductTypes.VER_NT_WORKSTATION))
|
||||||
|
{
|
||||||
|
if (suiteMask.HasFlag(WindowsSuites.Personal))
|
||||||
|
{
|
||||||
|
// Windows XP Home Edition
|
||||||
|
edition = "Home";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Windows XP / Windows 2000 Professional
|
||||||
|
edition = "Professional";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (productType.HasFlag(WindowsProductTypes.VER_NT_SERVER))
|
||||||
|
{
|
||||||
|
if (minorVersion == 0)
|
||||||
|
{
|
||||||
|
if (suiteMask.HasFlag(WindowsSuites.DataCenter))
|
||||||
|
{
|
||||||
|
// Windows 2000 Datacenter Server
|
||||||
|
edition = "Datacenter Server";
|
||||||
|
}
|
||||||
|
else if (suiteMask.HasFlag(WindowsSuites.Enterprise))
|
||||||
|
{
|
||||||
|
// Windows 2000 Advanced Server
|
||||||
|
edition = "Advanced Server";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Windows 2000 Server
|
||||||
|
edition = "Server";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (suiteMask.HasFlag(WindowsSuites.DataCenter))
|
||||||
|
{
|
||||||
|
// Windows Server 2003 Datacenter Edition
|
||||||
|
edition = "Datacenter";
|
||||||
|
}
|
||||||
|
else if (suiteMask.HasFlag(WindowsSuites.Enterprise))
|
||||||
|
{
|
||||||
|
// Windows Server 2003 Enterprise Edition
|
||||||
|
edition = "Enterprise";
|
||||||
|
}
|
||||||
|
else if (suiteMask.HasFlag(WindowsSuites.Blade))
|
||||||
|
{
|
||||||
|
// Windows Server 2003 Web Edition
|
||||||
|
edition = "Web Edition";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Windows Server 2003 Standard Edition
|
||||||
|
edition = "Standard";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (majorVersion == 6)
|
||||||
|
{
|
||||||
|
if (Kernel32Api.GetProductInfo(majorVersion, minorVersion, osVersionInfo.ServicePackMajor, osVersionInfo.ServicePackMinor, out var ed))
|
||||||
|
{
|
||||||
|
var memberInfo = ed.GetType().GetMember(ed.ToString()).FirstOrDefault();
|
||||||
|
|
||||||
|
if (memberInfo != null)
|
||||||
|
{
|
||||||
|
var descriptionAttribute = (DescriptionAttribute) memberInfo.GetCustomAttributes(typeof(DescriptionAttribute), false).FirstOrDefault();
|
||||||
|
edition = descriptionAttribute?.Description ?? "unknown";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
_sEdition = edition;
|
||||||
|
return edition;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string _name;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the name of the operating system running on this computer.
|
||||||
|
/// </summary>
|
||||||
|
public static string Name
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_name != null)
|
||||||
|
{
|
||||||
|
return _name; //***** RETURN *****//
|
||||||
|
}
|
||||||
|
|
||||||
|
var name = "unknown";
|
||||||
|
|
||||||
|
var osVersion = Environment.OSVersion;
|
||||||
|
var osVersionInfo = OsVersionInfoEx.Create();
|
||||||
|
if (!Kernel32Api.GetVersionEx(ref osVersionInfo))
|
||||||
|
{
|
||||||
|
_name = name;
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
var majorVersion = osVersion.Version.Major;
|
||||||
|
var minorVersion = osVersion.Version.Minor;
|
||||||
|
var productType = osVersionInfo.ProductType;
|
||||||
|
var suiteMask = osVersionInfo.SuiteMask;
|
||||||
|
switch (osVersion.Platform)
|
||||||
|
{
|
||||||
|
case PlatformID.Win32Windows:
|
||||||
|
if (majorVersion == 4)
|
||||||
|
{
|
||||||
|
var csdVersion = osVersionInfo.ServicePackVersion;
|
||||||
|
switch (minorVersion)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
if (csdVersion == "B" || csdVersion == "C")
|
||||||
|
{
|
||||||
|
name = "Windows 95 OSR2";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
name = "Windows 95";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
name = csdVersion == "A" ? "Windows 98 Second Edition" : "Windows 98";
|
||||||
|
break;
|
||||||
|
case 90:
|
||||||
|
name = "Windows Me";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PlatformID.Win32NT:
|
||||||
|
switch (majorVersion)
|
||||||
|
{
|
||||||
|
case 3:
|
||||||
|
name = "Windows NT 3.51";
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
switch (productType)
|
||||||
|
{
|
||||||
|
case WindowsProductTypes.VER_NT_WORKSTATION:
|
||||||
|
name = "Windows NT 4.0";
|
||||||
|
break;
|
||||||
|
case WindowsProductTypes.VER_NT_DOMAIN_CONTROLLER:
|
||||||
|
case WindowsProductTypes.VER_NT_SERVER:
|
||||||
|
name = "Windows NT 4.0 Server";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
switch (minorVersion)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
name = "Windows 2000";
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
switch (suiteMask)
|
||||||
|
{
|
||||||
|
case WindowsSuites.Personal:
|
||||||
|
name = "Windows XP Professional";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
name = "Windows XP";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
switch (suiteMask)
|
||||||
|
{
|
||||||
|
case WindowsSuites.Personal:
|
||||||
|
name = "Windows XP Professional x64";
|
||||||
|
break;
|
||||||
|
case WindowsSuites.Enterprise:
|
||||||
|
name = "Windows Server 2003 Enterprise";
|
||||||
|
break;
|
||||||
|
case WindowsSuites.DataCenter:
|
||||||
|
name = "Windows Server 2003 Data Center";
|
||||||
|
break;
|
||||||
|
case WindowsSuites.Blade:
|
||||||
|
name = "Windows Server 2003 Web Edition";
|
||||||
|
break;
|
||||||
|
case WindowsSuites.WHServer:
|
||||||
|
name = "Windows Home Server";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
name = "Windows Server 2003";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 6:
|
||||||
|
switch (minorVersion)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
switch (productType)
|
||||||
|
{
|
||||||
|
case WindowsProductTypes.VER_NT_SERVER:
|
||||||
|
name = "Windows Server 2008";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
name = "Windows Vista";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
switch (productType)
|
||||||
|
{
|
||||||
|
case WindowsProductTypes.VER_NT_SERVER:
|
||||||
|
name = "Windows Server 2008 R2";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
name = "Windows 7";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
name = "Windows 8";
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
name = "Windows 8.1";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 10:
|
||||||
|
name = "Windows 10";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
_name = name;
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the build version number of the operating system running on this computer.
|
||||||
|
/// </summary>
|
||||||
|
public static int BuildVersion => Environment.OSVersion.Version.Build;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the full version string of the operating system running on this computer.
|
||||||
|
/// </summary>
|
||||||
|
public static string VersionString
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return string.Format("{0}.{1} build {3} revision {2:X}", Environment.OSVersion.Version.Major, Environment.OSVersion.Version.Minor,
|
||||||
|
Environment.OSVersion.Version.Revision, Environment.OSVersion.Version.Build);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the full version of the operating system running on this computer.
|
||||||
|
/// </summary>
|
||||||
|
public static Version Version
|
||||||
|
{
|
||||||
|
get { return Environment.OSVersion.Version; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the major version number of the operating system running on this computer.
|
||||||
|
/// </summary>
|
||||||
|
public static int MajorVersion
|
||||||
|
{
|
||||||
|
get { return Environment.OSVersion.Version.Major; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the minor version number of the operating system running on this computer.
|
||||||
|
/// </summary>
|
||||||
|
public static int MinorVersion
|
||||||
|
{
|
||||||
|
get { return Environment.OSVersion.Version.Minor; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the revision version number of the operating system running on this computer.
|
||||||
|
/// </summary>
|
||||||
|
public static int RevisionVersion
|
||||||
|
{
|
||||||
|
get { return Environment.OSVersion.Version.Revision; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
88
src/Greenshot/Helpers/SingleExeHelper.cs
Normal file
88
src/Greenshot/Helpers/SingleExeHelper.cs
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
// Greenshot - a free and open source screenshot tool
|
||||||
|
// Copyright (C) 2007-2019 Thomas Braun, Jens Klingen, Robin Krom
|
||||||
|
//
|
||||||
|
// For more information see: http://getgreenshot.org/
|
||||||
|
// The Greenshot project is hosted on GitHub https://github.com/greenshot/greenshot
|
||||||
|
//
|
||||||
|
// This program is free software: you can redistribute it and/or modify
|
||||||
|
// it under the terms of the GNU General Public License as published by
|
||||||
|
// the Free Software Foundation, either version 1 of the License, or
|
||||||
|
// (at your option) any later version.
|
||||||
|
//
|
||||||
|
// This program is distributed in the hope that it will be useful,
|
||||||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
// GNU General Public License for more details.
|
||||||
|
//
|
||||||
|
// You should have received a copy of the GNU General Public License
|
||||||
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Reflection;
|
||||||
|
using Dapplo.Windows.Kernel32;
|
||||||
|
|
||||||
|
namespace Greenshot.Helpers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This is a helper class to handle the single-exe logic
|
||||||
|
/// </summary>
|
||||||
|
public static class SingleExeHelper
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Initialize the properties of this static helper, only called when the class is used
|
||||||
|
/// </summary>
|
||||||
|
static SingleExeHelper()
|
||||||
|
{
|
||||||
|
var assemblyLocation = Assembly.GetExecutingAssembly().Location;
|
||||||
|
if (string.IsNullOrEmpty(assemblyLocation) || assemblyLocation.EndsWith(".dll") != true)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Current process path
|
||||||
|
string currentProcessPath = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (var currentProcess = Process.GetCurrentProcess())
|
||||||
|
{
|
||||||
|
currentProcessPath = currentProcess.GetProcessPath();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(currentProcessPath))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Path.GetFileName(currentProcessPath).Equals("dotnet.exe", StringComparison.Ordinal))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SingleExeLocation = currentProcessPath;
|
||||||
|
IsRunningAsSingleExe = true;
|
||||||
|
UnpackPath = Path.GetDirectoryName(assemblyLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Is this process running as a single executable?
|
||||||
|
/// </summary>
|
||||||
|
public static bool IsRunningAsSingleExe { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Path to where the single exe is extracted
|
||||||
|
/// </summary>
|
||||||
|
public static string UnpackPath { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Location of the single exe
|
||||||
|
/// </summary>
|
||||||
|
public static string SingleExeLocation { get; }
|
||||||
|
}
|
||||||
|
}
|
|
@ -55,7 +55,12 @@ namespace Greenshot.Ui.Notifications.ViewModels
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Process.Start(StableDownloadLink);
|
var processStartInfo = new ProcessStartInfo(StableDownloadLink)
|
||||||
|
{
|
||||||
|
CreateNoWindow = true,
|
||||||
|
UseShellExecute = true
|
||||||
|
};
|
||||||
|
Process.Start(processStartInfo);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue