mirror of
https://github.com/greenshot/greenshot
synced 2025-08-21 14:03:23 -07:00
Fixed an issue with the build, where MSBuild.Community.Tasks.Targets wasn't found. Also improved the registry reading for the MAPI control.
This commit is contained in:
parent
328e7e569d
commit
2733c6cf26
7 changed files with 33 additions and 21 deletions
|
@ -20,6 +20,7 @@
|
|||
*/
|
||||
|
||||
using System.IO;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace GreenshotPlugin.Core {
|
||||
/// <summary>
|
||||
|
@ -27,16 +28,16 @@ namespace GreenshotPlugin.Core {
|
|||
/// </summary>
|
||||
public static class EmailConfigHelper {
|
||||
|
||||
public static string GetMapiClient() => RegistryHelper.ReadLocalMachineSoftwareKey(@"Clients\Mail");
|
||||
public static string GetMapiClient() => Registry.LocalMachine.ReadKey64Or32(@"Clients\Mail");
|
||||
|
||||
public static bool HasMapi()
|
||||
{
|
||||
var value = RegistryHelper.ReadLocalMachineSoftwareKey(@"Microsoft\Windows Messaging Subsystem", "MAPI", "0");
|
||||
var value = Registry.LocalMachine.ReadKey64Or32(@"Microsoft\Windows Messaging Subsystem", "MAPI", "0");
|
||||
return "1".Equals(value);
|
||||
|
||||
}
|
||||
|
||||
public static string GetOutlookExePath() => RegistryHelper.ReadLocalMachineSoftwareKey(@"Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE");
|
||||
public static string GetOutlookExePath() => Registry.LocalMachine.ReadKey64Or32(@"Microsoft\Windows\CurrentVersion\App Paths\OUTLOOK.EXE");
|
||||
|
||||
/// <summary>
|
||||
/// Check if Outlook is installed
|
||||
|
|
|
@ -27,22 +27,23 @@ namespace GreenshotPlugin.Core
|
|||
/// <summary>
|
||||
/// A helper class for accessing the registry
|
||||
/// </summary>
|
||||
public static class RegistryHelper
|
||||
public static class RegistryKeyExtensions
|
||||
{
|
||||
/// <summary>
|
||||
/// Retrieve a registry value
|
||||
/// </summary>
|
||||
/// <param name="registryKey">RegistryKey like Registry.LocalMachine</param>
|
||||
/// <param name="keyName">string with the name of the key</param>
|
||||
/// <param name="value">string with the name of the value below the key, null will retrieve the default</param>
|
||||
/// <param name="defaultValue">string with the default value to return</param>
|
||||
/// <returns>string with the value</returns>
|
||||
public static string ReadLocalMachineSoftwareKey(string keyName, string value = null, string defaultValue = null)
|
||||
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 = Registry.LocalMachine.OpenSubKey($@"SOFTWARE\{keyName}", false);
|
||||
using var key = registryKey.OpenSubKey($@"SOFTWARE\{keyName}", false);
|
||||
|
||||
if (key != null)
|
||||
{
|
||||
|
@ -52,7 +53,7 @@ namespace GreenshotPlugin.Core
|
|||
|
||||
if (string.IsNullOrEmpty(result))
|
||||
{
|
||||
using var key = Registry.LocalMachine.OpenSubKey($@"SOFTWARE\wow6432node\{keyName}", false);
|
||||
using var key = registryKey.OpenSubKey($@"SOFTWARE\wow6432node\{keyName}", false);
|
||||
|
||||
if (key != null)
|
||||
{
|
Loading…
Add table
Add a link
Reference in a new issue