add <modpath>/libraries/windows to the dll search path before loading Tolk. This enables nvdaControllerClient64.dll to be loaded in place.

master
Katie Durden 2023-04-04 22:22:36 -07:00
parent 1c61580d6b
commit 32db14b329
2 changed files with 16 additions and 0 deletions

View File

@ -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);
}

View File

@ -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();