1. Since MagickCoreGenesis() is already called before any other code can run and subsequent calls are ignored there's no way to set the execution path.
2. The automatically supplied path in MagickCoreGenesis() is always INVALID. Combined with 1 this is a huge frustration if all you want to do is to distribute the ImageMagick dlls with an appliction.
The offending code is in nt-base.c, the marked part needs to be deleted. MagickCoreGenesis() actually needs a path with a filename, stripping the filename ensures the path will always be ignored.
In nt-base.c:
Code: Select all
BOOL WINAPI DllMain(HINSTANCE handle,DWORD reason,LPVOID lpvReserved)
{
...
count=(ssize_t) GetModuleFileNameW(handle,wide_path,MaxTextExtent);
if (count != 0)
{
char
*path;
module_path=create_utf8_string(wide_path);
DELETE FROM HERE
for ( ; count > 0; count--)
if (module_path[count] == '\\')
{
module_path[count+1]='\0';
break;
}
DELETE TO HERE
MagickCoreGenesis(module_path,MagickFalse);
...
In magick.c:
Code: Select all
MagickExport void MagickCoreGenesis(const char *path,
const MagickBooleanType establish_signal_handlers)
{
...
#if defined(MAGICKCORE_WINDOWS_SUPPORT)
NTWindowsGenesis();
#endif
/*
Set client name and execution path.
*/
(void) GetExecutionPath(execution_path,MaxTextExtent);
if ((path != (const char *) NULL) &&
ONLY USE IF NOT WINDOWS
(*path == *DirectorySeparator) &&
END ONLY USE IF NOT WINDOWS
(IsPathAccessible(path) != MagickFalse))
(void) CopyMagickString(execution_path,path,MaxTextExtent);
GetPathComponent(execution_path,TailPath,filename);
(void) SetClientName(filename);
GetPathComponent(execution_path,HeadPath,execution_path);
(void) SetClientPath(execution_path);
...