41 lines
1.0 KiB
C#
41 lines
1.0 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace VideoReader;
|
|
|
|
public class InteropHelper
|
|
{
|
|
public const string LD_LIBRARY_PATH = "LD_LIBRARY_PATH";
|
|
|
|
public static void RegisterLibrariesSearchPath(string path)
|
|
{
|
|
switch (Environment.OSVersion.Platform)
|
|
{
|
|
case PlatformID.Win32S:
|
|
case PlatformID.Win32Windows:
|
|
case PlatformID.Win32NT:
|
|
SetDllDirectory(path);
|
|
break;
|
|
case PlatformID.Unix:
|
|
case PlatformID.MacOSX:
|
|
{
|
|
string environmentVariable = Environment.GetEnvironmentVariable("LD_LIBRARY_PATH");
|
|
if (!string.IsNullOrWhiteSpace(environmentVariable) && !environmentVariable.Contains(path))
|
|
{
|
|
char pathSeparator = Path.PathSeparator;
|
|
string value = environmentVariable + pathSeparator + path;
|
|
Environment.SetEnvironmentVariable("LD_LIBRARY_PATH", value);
|
|
}
|
|
break;
|
|
}
|
|
case PlatformID.WinCE:
|
|
case PlatformID.Xbox:
|
|
break;
|
|
}
|
|
}
|
|
|
|
[DllImport("kernel32", SetLastError = true)]
|
|
private static extern bool SetDllDirectory(string lpPathName);
|
|
}
|