4

I'm using SetDllDirectory (SetDllDirectoryW actually) to make some delay-loaded libraries load from a specific directory.
It goes like

if (SetDllDirectory(directory.c_str()) == 0)
{
    ERROR_MSG("Failed to set the current dll directory [%d]\n", GetLastError());
}

So everything works fine, most of the time, "f:/source/trunk 11" is fine and so on
But when it's called with "f:/source/trunk Gest hieß es !№;%()_@#$^&", i get ERROR_INVALID_PARAMETER from GetLastError. I am able to create a directory with such a name and i can work with it.
But what's so special with SetDllDirectory and "Gest hieß es !№;%()_@#$^&"? How can i fix it?

spiritwolfform
  • 2,263
  • 15
  • 16

1 Answers1

5

The problem is not the use of international characters. The problem is the semi-colon. For whatever reason, SetDllDirectory does not accept a semi-colon in the path that you supply. I cannot find any documentation for why this is so, but it's quite easy to check that it is so.

SetDllDirectoryW(L"aa")

will succeed, but

SetDllDirectoryW(L"a;a")

will fail.

The same is true for AddDllDirectory. Any path containing a semi-colon is rejected.

My guess is that internally Windows stores this information in a single string, using semi-colon as a separator. And because of this these functions have to reject paths that contain semi-colons.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • Related: [How check if given string is legal (allowed) file name under Windows?](http://stackoverflow.com/questions/62771/how-check-if-given-string-is-legal-allowed-file-name-under-windows) -- alas, I cannot test if this includes the `;`. The MSDN example only lists a few. – Jongware Sep 09 '14 at 09:41
  • One work-around that might work is to use the Short filename (DOS style). – MicroVirus Sep 09 '14 at 10:04