diff --git a/stardew-access/ScreenReader/NativeMethods.cs b/stardew-access/ScreenReader/NativeMethods.cs new file mode 100644 index 0000000..9e5b26a --- /dev/null +++ b/stardew-access/ScreenReader/NativeMethods.cs @@ -0,0 +1,8 @@ +using System; +using System.Runtime.InteropServices; + +public static class NativeMethods +{ + [DllImport("kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)] + public static extern bool SetDllDirectory(string lpPathName); +} diff --git a/stardew-access/ScreenReader/ScreenReaderWindows.cs b/stardew-access/ScreenReader/ScreenReaderWindows.cs index d9b2dbc..ee9ed5e 100644 --- a/stardew-access/ScreenReader/ScreenReaderWindows.cs +++ b/stardew-access/ScreenReader/ScreenReaderWindows.cs @@ -1,4 +1,5 @@ using DavyKager; +using System.IO; namespace stardew_access.ScreenReader { @@ -15,6 +16,13 @@ namespace stardew_access.ScreenReader public void InitializeScreenReader() { + if (MainClass.ModHelper is not null) + { + // Set the path to load Tolk.dll from + string dllDirectory = Path.Combine(MainClass.ModHelper.DirectoryPath, "libraries", "windows");; + // Call SetDllDirectory to change the DLL search path + NativeMethods.SetDllDirectory(dllDirectory); + } MainClass.InfoLog("Initializing Tolk..."); Tolk.TrySAPI(true); Tolk.Load();