SetDllDirectory

Is there a way to set multiple directories in the search path using SetDllDirectory

I've been able to get it to work for a single directory but I've subsequently found that this DLL is dependent on a number of other Dlls which are spread over different directories.

Calling SetDllDirectory twice resets the directory which is what you would expect, but have tried comma-separated and semi-colon separated directories in a single call both of which failed.

eg

[DllImport("kernel32.dll")]

public static extern bool SetDllDirectory(string pathName);

//and the call is:

bool result = SetDllDirectory(@"C:\Dir1;C:\Dir2");

Anyone tried / done this before



Answer this question

SetDllDirectory

  • zppro

    Apparently it is not possible to set multiple dll directories. In the initial spec this was in there but was later removed. Maybe it will return at some point in the future
  • webrod

    Hello,

    Maybe you could try Environment.SetEnvironmentVariable("PATH",.... instead.

    Richard


  • Ben Santiago

    I thought that too, but the client machine is locked down and I don't think I will have access to change this system variable. I am currently investigating explicitly using LoadLibrary on all the necessary DLLs.
  • SetDllDirectory