init commit
This commit is contained in:
40
desktop_global/VideoReader/InteropHelper.cs
Normal file
40
desktop_global/VideoReader/InteropHelper.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user