ExtensionManager: Added NeedsUpating function

This commit is contained in:
erri120 2019-10-30 18:19:37 +01:00
parent 74d16ed8b7
commit a12faee21e
No known key found for this signature in database
GPG Key ID: A8C0A18D8D4D3135
2 changed files with 9 additions and 11 deletions

View File

@ -28,6 +28,14 @@ namespace Wabbajack.Common
{"PerceivedType", "Compressed"}
};
public static bool NeedsUpdating(string appPath)
{
var progIDKey = Registry.CurrentUser.OpenSubKey(ProgIDPath);
var tempKey = progIDKey?.OpenSubKey("shell\\open\\command");
if (progIDKey == null || tempKey == null) return true;
return tempKey.GetValue("").ToString().Equals($"\"{appPath}\" -i \"%1\"");
}
public static bool IsAssociated(string appPath)
{
var progIDKey = Registry.CurrentUser.OpenSubKey(ProgIDPath);

View File

@ -86,17 +86,7 @@ namespace Wabbajack
}
var appPath = Assembly.GetExecutingAssembly().Location;
var iconPath = Path.Combine(Path.GetDirectoryName(appPath), "wabbajack.ico");
if(!File.Exists(iconPath))
{
using (var s = Utils.GetResourceStream("Wabbajack.UI.Icons.icon-embedded.ico"))
using (var fs = new FileStream(iconPath, FileMode.Create))
{
s.CopyTo(fs);
}
}
if (!ExtensionManager.IsAssociated(appPath))
if (!(ExtensionManager.IsAssociated(appPath) || ExtensionManager.NeedsUpdating(appPath)))
{
ExtensionManager.Associate(appPath);
}