Subject Embedded path
Author Adriano dos Santos Fernandes
Roman,

Attached is a patch to load the embedded (and the native client) in the
path of jaybird21.dll, as we discussed in fb-devel. It makes FB 2.5
fbembed.dll works ok without defining environment variables.

Could you apply it?


Adriano


----------

diff -ur src-old/client-java/src/native/jaygds/source/win32/platform.cpp src/client-java/src/native/jaygds/source/win32/platform.cpp
--- src-old/client-java/src/native/jaygds/source/win32/platform.cpp 2006-01-17 12:26:22.000000000 -0300
+++ src/client-java/src/native/jaygds/source/win32/platform.cpp 2008-05-12 08:04:29.714375000 -0300
@@ -27,6 +27,26 @@

#include "exceptions.h"

+
+static HINSTANCE hInstance = NULL;
+
+
+BOOL WINAPI DllMain(HINSTANCE h, DWORD reason, LPVOID reserved)
+{
+ switch (reason)
+ {
+ case DLL_PROCESS_ATTACH:
+ hInstance = h;
+ break;
+
+ default:
+ break;
+ }
+
+ return TRUE;
+}
+
+
void processFailedEntryPoint(const char* const message)
{
throw InternalException(message);
@@ -34,10 +54,31 @@

SHARED_LIBRARY_HANDLE PlatformLoadLibrary(const char* const name)
{
- SHARED_LIBRARY_HANDLE handle = LoadLibrary(name);
+ SHARED_LIBRARY_HANDLE handle = LoadLibraryEx(name, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
if (handle == NULL)
{
- throw InternalException("FirebirdApiBinding::Initialize - Could not find or load the GDS32.DLL");
+ char buffer[MAX_PATH];
+ DWORD dw;
+
+ if ((dw = GetModuleFileName(hInstance, buffer, sizeof(buffer))) != 0)
+ {
+ for (char* p = buffer + dw -1; p >= buffer; --p)
+ {
+ if (*p == '\\')
+ {
+ *p = '\0';
+ break;
+ }
+ }
+
+ strcat(buffer, "\\");
+ strcat(buffer, name);
+
+ handle = LoadLibraryEx(buffer, NULL, LOAD_WITH_ALTERED_SEARCH_PATH);
+ }
+
+ if (handle == NULL)
+ throw InternalException("FirebirdApiBinding::Initialize - Could not find or load the GDS32.DLL");
}
return handle;
}



[Non-text portions of this message have been removed]