FreeLibrary erreur constante(DLL c++)
Bonjour à tous!! C'est mon premier post ici.
Voila, j'ai un petit problème, j'essaye d'utiliser la méthode FreeLibrary pour libérer mon handle de DLL et ca me cause une exception lors de la fermeture de ma forme. Je peux cliquer dix fois sur mon bouton dans ma forme et cela ne me fait aucune erreur, c'est seulement a la fin que mon exception est soulevé.
Pourtant, j'ai suivi un tutoriel ici sur les DLL et je crois bien avoir suivi ce qu'il fallait faire a la lettre.
Voici mon code dans mon DLL que j'exporte:
Code:
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
| #include <vcl.h>
#include <windows.h>
#pragma hdrstop
#include "unit1.h"
#include <iostream>
#include <fstream>
using namespace std;
extern "C" __declspec(dllexport) __stdcall void Vic(int iWaiterNumber,int iInvoiceNumber,long lAmount,int iMode);
//Ici,c'est la fonction que j'ai rajouté
void __stdcall Vic(int iWaiterNumber,int iInvoiceNumber,long lAmount,int iMode)
{
string fichierSignet = "fichier.xml";
//Création du fichier texte
ofstream fichier(fichierSignet.c_str(),ios::out);
fichier << "Contenu du fichier34343" ;
fichier.close();
int Trans;
Trans=iWaiterNumber;
} |
Voila maintenant le code dans mon application ou j'utilise la fonction de mon dll qui crée un fichier xml .
Code:
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
|
void __fastcall TForm1::Button1Click(TObject *Sender)
{
typedef void ( __stdcall *MYDLLFUNC2) (int iWaiterNumber,int iInvoiceNumber,long lAmount,int iMode);
MYDLLFUNC2 ImpFuncDLL;
TDateTime dtAfter, dtBefore;
String DayApres;
BOOL fFreeResult;
int Retour;
int iRet;
String DLLSource="pjXMLDLL.dll";
if (hinstDLL=LoadLibrary("pjXMLDLL.dll")) {
ImpFuncDLL = (MYDLLFUNC2)GetProcAddress(hinstDLL, "Vic");
if (ImpFuncDLL)
{
ImpFuncDLL(14,1,134.56,5);
FreeLibrary(hinstDLL);
}
}
} |
Voila, je fais le freelibrary a la bonne place pourtant, qqun pourrait m'éclairez svplait!!
Sam