From bdddc726b437cd03584c72de63493d7579e4e30e Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Mon, 4 Apr 2016 18:18:59 +0000 Subject: [PATCH] Load libpq.dll with full path, so the LoadLibrary does not accidentally take a different (probably wrong) one from somewhere else than the current directory. See http://www.heidisql.com/forum.php?t=21039 --- source/dbconnection.pas | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/dbconnection.pas b/source/dbconnection.pas index 3f5270cd..9f508aa5 100644 --- a/source/dbconnection.pas +++ b/source/dbconnection.pas @@ -2090,12 +2090,15 @@ end; procedure TPgConnection.DoBeforeConnect; +var + LibWithPath: String; begin // Init lib before actually connecting. // Each connection has its own library handle if LibPqHandle = 0 then begin - Log(lcDebug, f_('Loading library file %s ...', [LibPqPath])); - LibPqHandle := LoadLibrary(PWideChar(LibPqPath)); + LibWithPath := ExtractFileDir(Application.ExeName) + '\' + LibPqPath; + Log(lcDebug, f_('Loading library file %s ...', [LibWithPath])); + LibPqHandle := LoadLibrary(PWideChar(LibWithPath)); if LibPqHandle = 0 then raise EDatabaseError.CreateFmt(_('Cannot find a usable %s. Please launch %s from the directory where you have installed it.'), [LibPqPath, ExtractFileName(ParamStr(0))]) else begin