Bonjour,
Je souhaite charger un DLL dans mon programme et appeller une fonction contenu dans celle-ci.
Pour l'instant, je fais ça :
Le loadLibrary passe bien et me renvoi une DLL.
Code : 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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54 AnsiString texte; TPath path; texte = "C:\\PJ_Octopus_V1.0\\Source\\bin\\plugins\\PLG_SimplePlugin\\Technics\\TCH_Brillance\\TCH_Brillance.dll"; //texte = "C:\\msimusic.dll"; path = texte; cout << path.toString().c_str() << endl; if(path.isValidPath()) { //chargement du plugin HINSTANCE hDLL; DLL_TECHNIC_FUNC_TYPE callFunction; hDLL = LoadLibrary(path.toString().c_str()); if(hDLL == NULL) { texte = "hDLL: "; texte += (int)hDLL; cout << texte.c_str() << endl; texte = "TObjetRunImpl::loadProcess-> erreur loadLibrary"; cout << texte.c_str() << endl; HRESULT reponse = GetLastError(); texte = "Error: "; texte += reponse; cout << texte.c_str() << endl; analyseReponse(reponse, "loadLibrary"); } else { callFunction = (DLL_TECHNIC_FUNC_TYPE) GetProcAddress(hDLL, DLL_TECHNIC_FUNC_NAME.c_str()); //callFunction = (void *) GetProcAddress(hDLL, DLL_TECHNIC_FUNC_NAME.c_str()); if(callFunction == NULL) { texte = "TObjetRunImpl::loadProcess-> "+ERROR_TECHNIC_FUNCTION; cout << texte.c_str() << endl; FreeLibrary(hDLL); } else { ITechnic *technic = callFunction(); } } } else { texte = "TObjetRunImpl::loadProcess-> "+ERROR_TECHNIC_FILE; cout << texte.c_str() << endl; } system("PAUSE"); return 0;
Le GetProcAddress à l'air de trouver la fonction puisque il me renvoi un pointeur non NULL.
Par contre, quand j'essaie d'exécuter la fonction, j'ai une violation d'accès.
J'ai essayer le mode debug pas-à-pas en rentrant dans la fonction callFunction, mais dès que j'essaie de rentrer dedans, j'ai violation d'accès.
Une idée?







Répondre avec citation




Cafuro est un outil SNMP dont le but est d'aider les administrateurs système et réseau à configurer leurs équipements SNMP réseau.

Partager