Bonjour (et bonne année 2015)
Environnement : Windows : 64 bits

- J'ai téléchargé postgresql-9.4.0-1-windows-binaries.zip et postgresql-9.4.0-1-windows-x64-binaries.zip pour avoir
libpq.dll et libintl.dll (32 bits)
libpq.dll et libintl-8.dll (64 bits)

- Avec dumpbin de Visual Studio 12.0 j'ai bien vérifié que j'avais bien des versions 32 bits et 64 bits

- Avec Windev version 18

1° je compile mon application pour du 32bits : tout fonctionne à 100%

2° je compile mon application pour du 64 bits : Impossible de charger la dll libpq.dll
Message d'erreur : "libpq.dll n'est pas une application Win32 valide"

Si je test avec la fonction : LoadLibraryA au lieu d'utiliser la fonction LoadDll() de Windev :

DLLName1 est une chaîne = PathOfDll + "libintl-8.dll"
handleDLL1 est un entier système = API("Kernel32.dll", "LoadLibraryA", &DLLName1) // ---> handleDLL <> 0 c'est OK

DLLName2 est une chaîne = PathOfDll + "libpq.dll"
handleDLL2 est un entier système = API("Kernel32.dll", "LoadLibraryA", &DLLName2) // ---> handleDLL = 0 c'est bad

---------------------------------------------------------------------------------------------------------------------------
Test fait en VB avec Visual Studio 12 :

Code VB : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
Module Module1
    Private Declare Function LoadLibraryA Lib "kernel32" Alias "LoadLibraryA" (ByVal lpFileName As String) As Long
 
    Sub Main()
        Dim hnd As Long
        Dim DllName As String
 
        DllName = "D:\Mes Projets\LIBPQ\Exe\Exécutable Windows 64 bits\EnCours-libpq64\libintl-8.dll"
        hnd = LoadLibraryA(DllName)
        MsgBox(hnd, MsgBoxStyle.Information, "libintl-8.dll")
 
        DllName = "D:\Mes Projets\LIBPQ\Exe\Exécutable Windows 64 bits\EnCours-libpq64\libpq.dll"
        hnd = LoadLibraryA(DllName)
        MsgBox(hnd, MsgBoxStyle.Information, "libpq.dll")
 
    End Sub
End Module

------ Début de la génération : Projet : ConsoleApplication2, Configuration : Debug x64 ------
ConsoleApplication2 -> D:\VS2013\ConsoleApplication2\ConsoleApplication2\bin\x64\Debug\ConsoleApplication2.exe
========== Génération : 1 a réussi, 0 a échoué, 0 mis à jour, 0 a été ignoré ==========

libintl-8.dll renvoi hnd <> 0
libpq.dll renvoi hnd = 0
---------------------------------------------------------------------------------------------------------------------------
Test fait en VC avec Visual Studio 12 :

Code C : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
 
#include "stdafx.h"
#include <windows.h>
#include <stdio.h>
#include <conio.h>
 
int _tmain(int argc, _TCHAR* argv[])
{
    HINSTANCE hinstLib;
    DWORD nErrorCode;
    CHAR* msg;
 
    //LPCSTR DllName = "D:\\Mes Projets\\LIBPQ\\Exe\\Exécutable Windows 64 bits\\EnCours-libpq64\\libintl-8.dll";
    LPCSTR DllName = "D:\\Mes Projets\\LIBPQ\\Exe\\Exécutable Windows 64 bits\\EnCours-libpq64\\libpq.dll";
    hinstLib = LoadLibraryA(DllName);
 
    if (hinstLib == NULL)
    {
        nErrorCode = GetLastError();
        FormatMessageA(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
                       NULL,
                       nErrorCode,
                       MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
                       (LPSTR)&msg,
                       0,
                       NULL);
        printf("Erreur : %d\n%s\n", nErrorCode, msg);            // nErrorCode = 193
    }
    else
    {
        FreeLibrary(hinstLib);
        printf("%s\n", "Ok");
    }
    return 0;
}
1>------ Début de la génération : Projet : ConsoleApplication4, Configuration : Debug x64 ------
1> ConsoleApplication4.cpp
1> ConsoleApplication4.vcxproj -> D:\VS2013\ConsoleApplication4\x64\Debug\ConsoleApplication4.exe
========== Génération : 1 a réussi, 0 a échoué, 0 mis à jour, 0 a été ignoré ==========
pour libintl-8.dll -> ok
pour libpq.dll -> Erreur : 193
%1 n'est pas une application Win32 valide. (message identique !)

Sauf erreur de ma part, le problème me semble de moins en moins lié au langage mais plus à libpq.dll version 64 bits.