Skip to content

Commit

Permalink
fix: generate path based on BootDir in Registry to distinguish betwee…
Browse files Browse the repository at this point in the history
…n 4024 and 4026 (#108)

Paths for OEM-Licenses changed in Twincat 3.1.4026.x; In order to be compatible with Twinpack, now the right path for licenses is chosen depending on the Twincat installation 4026 or 4024

(cherry picked from commit 8a7ac5e)
  • Loading branch information
seehma committed Nov 21, 2023
1 parent 48dfaa6 commit b741026
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions TwinpackShared/TwinpackUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
using EnvDTE80;
using System.Windows.Media.Imaging;
using System.Security.Cryptography;
using Microsoft.Win32;

namespace Twinpack
{
Expand All @@ -29,8 +30,31 @@ public class TwinpackUtils
private static readonly Guid _libraryManagerGuid = Guid.Parse("e1825adc-a79c-4e8e-8793-08d62d84be5b");
public static string DefaultLibraryCachePath { get { return $@"{Directory.GetCurrentDirectory()}\.Zeugwerk\libraries"; } }

public static string TwincatPath { get { return Environment.GetEnvironmentVariable("TWINCAT3DIR") ?? @"C:\TwinCAT\3.1\"; } }
public static string LicensesPath = TwincatPath + @"CustomConfig\Licenses";
public static string TwincatPath
{
get
{
try
{
using (RegistryKey key = Registry.LocalMachine.OpenSubKey("Software\\Wow6432Node\\Beckhoff\\TwinCAT3\\3.1"))
{
var bootDir = key?.GetValue("BootDir") as string;

// need to do GetParent twice because of the trailing \
return bootDir == null ? null : new DirectoryInfo(bootDir)?.Parent?.FullName;
}
}
catch
{
return null;
}

return null;
}
}

public static string LicensesPath = TwincatPath + @"\CustomConfig\Licenses";
public static string BootFolderPath = TwincatPath + @"\Boot";

private static readonly Logger _logger = LogManager.GetCurrentClassLogger();

Expand Down

0 comments on commit b741026

Please sign in to comment.