From 3f07f717996979b01c70487e581d1d690de1a269 Mon Sep 17 00:00:00 2001 From: perry.werneck@gmail.com Date: Tue, 5 Mar 2013 15:03:24 +0000 Subject: [PATCH] Melhorando a carga de DLLs e plugins no windows --- src/plugins/remotectl/calls.c | 11 ++++++++--- src/pw3270/plugin.c | 13 +++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/plugins/remotectl/calls.c b/src/plugins/remotectl/calls.c index a310edf..7d06538 100644 --- a/src/plugins/remotectl/calls.c +++ b/src/plugins/remotectl/calls.c @@ -139,8 +139,9 @@ AddDllDirectory = (HANDLE (*)(PCWSTR)) GetProcAddress(kernel,"AddDllDirectory"); RemoveDllDirectory = (BOOL (*)(HANDLE)) GetProcAddress(kernel,"RemoveDllDirectory"); - // Notify user in case of error loading protocol DLL - errorMode = SetErrorMode(0); + // Notify user in case of error loading protocol DLL + // http://msdn.microsoft.com/en-us/library/windows/desktop/ms680621(v=vs.85).aspx + errorMode = SetErrorMode(1); memset(datadir,' ',4095); datadir[4095] = 0; @@ -165,8 +166,12 @@ trace("%s hModule=%p rc=%d",buffer,hModule,(int) GetLastError()); - if(hModule == NULL) + if(hModule == NULL) + { + // Enable DLL error popup and try again with full path + SetErrorMode(0) hModule = LoadLibraryEx(buffer,NULL,LOAD_LIBRARY_SEARCH_DEFAULT_DIRS|LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR); + } rc = GetLastError(); diff --git a/src/pw3270/plugin.c b/src/pw3270/plugin.c index 931f2b7..4b6ad1b 100644 --- a/src/pw3270/plugin.c +++ b/src/pw3270/plugin.c @@ -45,6 +45,10 @@ const gchar * name; GError * err = NULL; GList * lst = NULL; +#ifdef WIN32 + UINT errorMode; +#endif // WIN32 + trace("Loading plugins from %s",path); @@ -59,6 +63,11 @@ return; } +#ifdef WIN32 + // http://msdn.microsoft.com/en-us/library/windows/desktop/ms680621(v=vs.85).aspx + errorMode = SetErrorMode(1); +#endif // WIN32 + name = g_dir_read_name(dir); while(name) { @@ -104,6 +113,10 @@ name = g_dir_read_name(dir); } +#ifdef WIN32 + SetErrorMode(errorMode); +#endif // WIN32 + g_dir_close(dir); if(lst) -- libgit2 0.21.2