Commit 60197c22 authored by Mukund Sivaraman's avatar Mukund Sivaraman

windows: Call SetDLLDirectory() in the app

With this patch, there should be no more need to set PATH on Windows
before running GIMP.

This patch was tested by me and drawoc, but there could be some
undetected issues lurking. Revert if any problems arise.
parent 02fd23e3
......@@ -318,6 +318,40 @@ main (int argc,
if (p_SetDllDirectoryA)
(*p_SetDllDirectoryA) ("");
}
/* On Windows, set DLL search path to $INSTALLDIR/bin so that .exe
plug-ins in the plug-ins directory can find libgimp and file
library DLLs without needing to set external PATH. */
{
const gchar *install_dir;
gchar *bin_dir;
LPWSTR w_bin_dir;
int n;
w_bin_dir = NULL;
install_dir = gimp_installation_directory ();
bin_dir = g_build_filename (install_dir, "bin", NULL);
n = MultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
bin_dir, -1, NULL, 0);
if (n == 0)
goto out;
w_bin_dir = g_malloc_n (n + 1, sizeof (wchar_t));
n = MultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
bin_dir, -1,
w_bin_dir, (n + 1) * sizeof (wchar_t));
if (n == 0)
goto out;
SetDllDirectoryW (w_bin_dir);
out:
if (w_bin_dir)
g_free (w_bin_dir);
g_free (bin_dir);
}
#ifndef _WIN64
{
typedef BOOL (WINAPI *t_SetProcessDEPPolicy) (DWORD dwFlags);
......
......@@ -261,6 +261,40 @@ gimp_main (const GimpPlugInInfo *info,
if (p_SetDllDirectoryA)
(*p_SetDllDirectoryA) ("");
}
/* On Windows, set DLL search path to $INSTALLDIR/bin so that GEGL
file operations can find their respective file library DLLs (such
as jasper, etc.) without needing to set external PATH. */
{
const gchar *install_dir;
gchar *bin_dir;
LPWSTR w_bin_dir;
int n;
w_bin_dir = NULL;
install_dir = gimp_installation_directory ();
bin_dir = g_build_filename (install_dir, "bin", NULL);
n = MultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
bin_dir, -1, NULL, 0);
if (n == 0)
goto out;
w_bin_dir = g_malloc_n (n + 1, sizeof (wchar_t));
n = MultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
bin_dir, -1,
w_bin_dir, (n + 1) * sizeof (wchar_t));
if (n == 0)
goto out;
SetDllDirectoryW (w_bin_dir);
out:
if (w_bin_dir)
g_free (w_bin_dir);
g_free (bin_dir);
}
#ifndef _WIN64
{
typedef BOOL (WINAPI *t_SetProcessDEPPolicy) (DWORD dwFlags);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment