diff --git a/Directory.Build.props b/Directory.Build.props
index 520eb0976..ce53be91e 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -102,11 +102,14 @@
-
-
+
+
+
+ $(userprofile)\.nuget\packages\msbuildtasks\1.5.0.235\tools\
+
-
+
diff --git a/Greenshot/Greenshot.csproj b/Greenshot/Greenshot.csproj
index 9419fb179..630501ce8 100644
--- a/Greenshot/Greenshot.csproj
+++ b/Greenshot/Greenshot.csproj
@@ -46,6 +46,13 @@
Always
+
+
+
+ all
+ runtime; build; native; contentfiles; analyzers; buildtransitive
+
+
diff --git a/Greenshot/Helpers/MailHelper.cs b/Greenshot/Helpers/MailHelper.cs
index d3daaf446..a78799eae 100644
--- a/Greenshot/Helpers/MailHelper.cs
+++ b/Greenshot/Helpers/MailHelper.cs
@@ -174,7 +174,7 @@ namespace Greenshot.Helpers {
///
public void ShowDialog() {
// Create the mail message in an STA thread
- var thread = new Thread(_ShowMail)
+ var thread = new Thread(ShowMail)
{
IsBackground = true,
Name = "Create MAPI mail"
@@ -202,7 +202,7 @@ namespace Greenshot.Helpers {
///
/// Sends the mail message.
///
- private void _ShowMail() {
+ private void ShowMail() {
var message = new MapiHelperInterop.MapiMessage();
using var interopRecipients = Recipients.GetInteropRepresentation();
@@ -215,7 +215,7 @@ namespace Greenshot.Helpers {
// Check if we need to add attachments
if (Files.Count > 0) {
// Add attachments
- message.Files = _AllocAttachments(out message.FileCount);
+ message.Files = AllocAttachments(out message.FileCount);
}
// Signal the creating thread (make the remaining code async)
@@ -227,7 +227,7 @@ namespace Greenshot.Helpers {
if (Files.Count > 0) {
// Deallocate the files
- _DeallocFiles(message);
+ DeallocFiles(message);
}
MAPI_CODES errorCode = (MAPI_CODES)Enum.ToObject(typeof(MAPI_CODES), error);
@@ -245,14 +245,14 @@ namespace Greenshot.Helpers {
return;
}
Recipients = new RecipientCollection();
- _ShowMail();
+ ShowMail();
}
///
/// Deallocates the files in a message.
///
/// The message to deallocate the files from.
- private void _DeallocFiles(MapiHelperInterop.MapiMessage message) {
+ private void DeallocFiles(MapiHelperInterop.MapiMessage message) {
if (message.Files != IntPtr.Zero) {
Type fileDescType = typeof(MapiFileDescriptor);
int fsize = Marshal.SizeOf(fileDescType);
@@ -274,7 +274,7 @@ namespace Greenshot.Helpers {
///
///
///
- private IntPtr _AllocAttachments(out int fileCount) {
+ private IntPtr AllocAttachments(out int fileCount) {
fileCount = 0;
if (Files == null) {
return IntPtr.Zero;
diff --git a/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj b/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj
index 2c4e72fe6..d37465111 100644
--- a/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj
+++ b/GreenshotJiraPlugin/GreenshotJiraPlugin.csproj
@@ -12,7 +12,7 @@
-
-
+
+
\ No newline at end of file
diff --git a/GreenshotPlugin/Core/EmailConfigHelper.cs b/GreenshotPlugin/Core/EmailConfigHelper.cs
index 7da960b09..354f02c33 100644
--- a/GreenshotPlugin/Core/EmailConfigHelper.cs
+++ b/GreenshotPlugin/Core/EmailConfigHelper.cs
@@ -1,6 +1,6 @@
/*
* Greenshot - a free and open source screenshot tool
- * Copyright (C) 2007-2020 Thomas Braun, Jens Klingen, Robin Krom
+ * Copyright (C) 2007-2021 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
@@ -18,6 +18,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
+
using System.IO;
using Microsoft.Win32;
@@ -26,38 +27,17 @@ namespace GreenshotPlugin.Core {
/// Description of EmailConfigHelper.
///
public static class EmailConfigHelper {
- private const string OutlookPathKey = @"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE";
- private const string MapiClientKey = @"SOFTWARE\Clients\Mail";
- private const string MapiLocationKey = @"SOFTWARE\Microsoft\Windows Messaging Subsystem";
- private const string MapiKey = @"MAPI";
- public static string GetMapiClient() {
- using (RegistryKey key = Registry.CurrentUser.OpenSubKey(MapiClientKey, false)) {
- if (key != null) {
- return (string)key.GetValue(string.Empty);
- }
- }
- using (RegistryKey key = Registry.LocalMachine.OpenSubKey(MapiClientKey, false))
- {
- return (string) key?.GetValue(string.Empty);
- }
- }
-
- public static bool HasMapi()
- {
- using RegistryKey key = Registry.LocalMachine.OpenSubKey(MapiLocationKey, false);
- return key != null && "1".Equals(key.GetValue(MapiKey, "0"));
- }
+ public static string GetMapiClient() => Registry.LocalMachine.ReadKey64Or32(@"Clients\Mail");
- public static string GetOutlookExePath() {
- using (RegistryKey key = Registry.LocalMachine.OpenSubKey(OutlookPathKey, false)) {
- if (key != null) {
- // "" is the default key, which should point to the outlook location
- return (string)key.GetValue(string.Empty);
- }
- }
- return null;
+ public static bool HasMapi()
+ {
+ var value = Registry.LocalMachine.ReadKey64Or32(@"Microsoft\Windows Messaging Subsystem", "MAPI", "0");
+ return "1".Equals(value);
+
}
+
+ public static string GetOutlookExePath() => Registry.LocalMachine.ReadKey64Or32(@"Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE");
///
/// Check if Outlook is installed
@@ -65,12 +45,11 @@ namespace GreenshotPlugin.Core {
/// Returns true if outlook is installed
public static bool HasOutlook() {
string outlookPath = GetOutlookExePath();
- if (outlookPath != null) {
- if (File.Exists(outlookPath)) {
- return true;
- }
+ if (outlookPath == null)
+ {
+ return false;
}
- return false;
+ return File.Exists(outlookPath);
}
}
}
diff --git a/GreenshotPlugin/Core/RegistryKeyExtensions.cs b/GreenshotPlugin/Core/RegistryKeyExtensions.cs
new file mode 100644
index 000000000..73fd66a47
--- /dev/null
+++ b/GreenshotPlugin/Core/RegistryKeyExtensions.cs
@@ -0,0 +1,67 @@
+/*
+ * Greenshot - a free and open source screenshot tool
+ * Copyright (C) 2007-2021 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 .
+ */
+
+using System;
+using Microsoft.Win32;
+
+namespace GreenshotPlugin.Core
+{
+ ///
+ /// A helper class for accessing the registry
+ ///
+ public static class RegistryKeyExtensions
+ {
+ ///
+ /// Retrieve a registry value
+ ///
+ /// RegistryKey like Registry.LocalMachine
+ /// string with the name of the key
+ /// string with the name of the value below the key, null will retrieve the default
+ /// string with the default value to return
+ /// string with the value
+ public static string ReadKey64Or32(this RegistryKey registryKey, string keyName, string value = null, string defaultValue = null)
+ {
+ string result = null;
+ value ??= string.Empty;
+ if (Environment.Is64BitOperatingSystem)
+ {
+ using var key = registryKey.OpenSubKey($@"SOFTWARE\{keyName}", false);
+
+ if (key != null)
+ {
+ result = (string)key.GetValue(value, defaultValue);
+ }
+ }
+
+ if (string.IsNullOrEmpty(result))
+ {
+ using var key = registryKey.OpenSubKey($@"SOFTWARE\wow6432node\{keyName}", false);
+
+ if (key != null)
+ {
+ result = (string)key.GetValue(value, defaultValue);
+ }
+ }
+
+ return result;
+ }
+ }
+}
diff --git a/GreenshotPlugin/GreenshotPlugin.csproj b/GreenshotPlugin/GreenshotPlugin.csproj
index 3caa4a7c4..29371bcfd 100644
--- a/GreenshotPlugin/GreenshotPlugin.csproj
+++ b/GreenshotPlugin/GreenshotPlugin.csproj
@@ -13,9 +13,9 @@
-
+
-
+