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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
#include "stdafx.h"
#include "resource.h"
#include <initguid.h>
#include "DLLTEST.h"
#include <fstream>
#include <string>
#include "DLLTEST.c"
// Taille maximale de l'url
#define TAILLE_MAX 1000
using namespace std;
char CODEERREUR;
string LIBELLEERREUR;
char MODEDECONNEXION;
string GetURL() {
ifstream fichierConfig("DLLTEST.config" );
string pURL = "";
if (fichierConfig) {
getline(fichierConfig,pURL);
if (pURL == "") {
CODEERREUR = '9';
LIBELLEERREUR = "Fichier DLLTEST.config vide";
MODEDECONNEXION = 'S';
return pURL;
}
} else {
// Si fichier introuvable
CODEERREUR = '9';
LIBELLEERREUR = "Fichier DLLTEST.config non trouvé";
MODEDECONNEXION = 'S';
return pURL;
}
return pURL;
}
string __stdcall GetTypeConnexion(string PS_szTypeConnexion, string PS_szLibelleErreur) {
// Chargement du module DLL
HINSTANCE hDLL = LoadLibrary("uneautredlldotnetacharger.dll");
string modeCnx;
string codeErr;
if (hDLL != NULL) {
typedef char *DLL_Function_getTypeConnexion (string pURL);
// instantiation de la fonction getTypeConnexion
DLL_Function_getTypeConnexion *fn_getTypeConnexion;
// Chargement en mémoire
fn_getTypeConnexion = (DLL_Function_getTypeConnexion*)GetProcAddress(hDLL,"getTypeConnexion");
// Lecture de l'url sur DLLTEST.config
string pURL = GetURL();
if (pURL != "") {
// Appel de la méthode getTypeConnexion()
MODEDECONNEXION = *fn_getTypeConnexion(pURL);
} else {
MODEDECONNEXION = 'S';
}
modeCnx = MODEDECONNEXION;
codeErr = CODEERREUR;
FreeLibrary(hDLL);
}
return string(modeCnx) + string(codeErr) + LIBELLEERREUR;
} |
Partager