Skip to content

Commit

Permalink
Try to load libpq.dll with explicit file path if the path-less did no…
Browse files Browse the repository at this point in the history
  • Loading branch information
ansgarbecker committed Nov 20, 2016
1 parent 41b7578 commit ce444cb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion out/locale/en/LC_MESSAGES/default.po
Expand Up @@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: HeidiSQL\n"
"POT-Creation-Date: 2012-11-05 21:40\n"
"PO-Revision-Date: 2016-09-04 13:00+0200\n"
"PO-Revision-Date: 2016-11-20 22:19+0100\n"
"Last-Translator: Ansgar Becker <anse@heidisql.com>\n"
"Language-Team: English (http://www.transifex.com/projects/p/heidisql/"
"language/en/)\n"
Expand Down Expand Up @@ -4013,6 +4013,9 @@ msgstr "OLE DB property \"%s\": %s"
msgid "Loading library file %s ..."
msgstr "Loading library file %s ..."

msgid "Trying to load library with full path: %s"
msgstr "Trying to load library with full path: %s"

#. DLL loading fails on one procedure
msgid "Library error in %s: Could not find procedure address for \"%s\""
msgstr "Library error in %s: Could not find procedure address for \"%s\""
Expand Down
8 changes: 8 additions & 0 deletions source/dbconnection.pas
Expand Up @@ -2117,12 +2117,20 @@ procedure TMySQLConnection.DoBeforeConnect;


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));
if LibPqHandle = 0 then begin
// Try with explicit file path if the path-less did not succeed. See http://www.heidisql.com/forum.php?t=22514
LibWithPath := ExtractFileDir(Application.ExeName) + '\' + LibPqPath;
Log(lcInfo, f_('Trying to load library with full path: %s', [LibWithPath]));
LibPqHandle := LoadLibrary(PWideChar(LibWithPath));
end;
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
Expand Down

0 comments on commit ce444cb

Please sign in to comment.