Skip to content

Instantly share code, notes, and snippets.

@viniciusjarina
Created August 25, 2014 16:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save viniciusjarina/9050b53255a3d876de2e to your computer and use it in GitHub Desktop.
Save viniciusjarina/9050b53255a3d876de2e to your computer and use it in GitHub Desktop.
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