设置非托管DLL加载目录
我需要从一个特定的目录加载一个库。 我不想使用LoadLibrary(Windows)或dlopen(Linux)等特定功能,而是暂时将此文件夹添加到搜索路径中。
所以我有:
public static void AddOrUpdateDllPath(string dllDirectory)
{
dllDirectory = dllDirectory.NormalizePathDelimiters("");
var path = "";
switch (RunningPlatform)
{
case OperatingSystem.Windows:
path = "PATH";
Environment.SetEnvironmentVariable(path, Environment.GetEnvironmentVariable(path) + ";" + dllDirectory);
break;
case OperatingSystem.MacOS:
path = "LD_LIBRARY_PATH";
throw new NotImplementedException("How to change " + path);
break;
case OperatingSystem.Linux:
path = "DYLD_FRAMEWORK_PATH";
throw new NotImplementedException("How to change " + path);
break;
}
}
我不知道如何为Linux和MaxOS添加路径变量?
链接地址: http://www.djcxy.com/p/44589.html