bloxstrap/Bloxstrap/Utility/Shortcut.cs
pizzaboxer 8b74470f6c
Convert AssemblyLoadStatus to a generic enum
i might need this for other things
2023-10-27 22:24:59 +01:00

41 lines
1.3 KiB
C#

using System.Windows;
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(
$"{App.ProjectName} was unable to create shortcuts for the Desktop and Start menu. They will be created the next time Roblox is launched.",
MessageBoxImage.Information
);
}
}
}
}