bloxstrap/Bloxstrap/Utility/Shortcut.cs
pizzaboxer 776dbc4097
Draft: new installer system
the beginning of a long arduous cleanup of two years of debt
2024-08-10 13:08:04 +01:00

39 lines
1.2 KiB
C#

using System.Windows;
using Bloxstrap.Resources;
namespace Bloxstrap.Utility
{
internal static class Shortcut
{
private static GenericTriState _loadStatus = GenericTriState.Unknown;
public static void Create(string exePath, string exeArgs, string lnkPath)
{
const string LOG_IDENT = "Shortcut::Create";
if (File.Exists(lnkPath))
return;
try
{
ShellLink.Shortcut.CreateShortcut(exePath, exeArgs, exePath, 0).WriteToFile(lnkPath);
if (_loadStatus != GenericTriState.Successful)
_loadStatus = GenericTriState.Successful;
}
catch (FileNotFoundException ex)
{
App.Logger.WriteLine(LOG_IDENT, $"Failed to create a shortcut for {lnkPath}!");
App.Logger.WriteException(LOG_IDENT, ex);
if (_loadStatus == GenericTriState.Failed)
return;
_loadStatus = GenericTriState.Failed;
Frontend.ShowMessageBox(Strings.Dialog_CannotCreateShortcuts, MessageBoxImage.Information);
}
}
}
}