Created
August 25, 2014 16:59
-
-
Save viniciusjarina/9050b53255a3d876de2e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Runtime.InteropServices; | |
namespace AR.Drone.Infrastructure | |
{ | |
public static class InteropHelper | |
{ | |
public const string LD_LIBRARY_PATH = "LD_LIBRARY_PATH"; | |
public static void RegisterLibrariesSearchPath(string path) | |
{ | |
switch (Environment.OSVersion.Platform) | |
{ | |
case PlatformID.Win32NT: | |
case PlatformID.Win32S: | |
case PlatformID.Win32Windows: | |
SetDllDirectory(path); | |
break; | |
case PlatformID.Unix: | |
case PlatformID.MacOSX: | |
string currentValue = Environment.GetEnvironmentVariable(LD_LIBRARY_PATH) ?? string.Empty; | |
string newValue = string.IsNullOrEmpty(currentValue) ? path : currentValue + Path.PathSeparator + path; | |
Environment.SetEnvironmentVariable(LD_LIBRARY_PATH, newValue); | |
break; | |
} | |
} | |
[DllImport("kernel32", SetLastError = true)] | |
public static extern bool SetDllDirectory(string lpPathName); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment