Bonjour, j'ai deja parcouru le forum et tente d'utiliser
http://www.developpez.net/forums/viewtopic.php?t=252919
ca a marche une fois puis plus, j'accede a la DLL, mais je n'arrive pas a acceder aux fonctions, qq'un pourrait m'eclaircir ?
code pour la DLL
code pour le prog
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 #include <windows.h> #include <string> using namespace std; #define DllImport __declspec( dllimport ) #define DllExport __declspec( dllexport ) /* DllClass::DllClass() {} DllClass::~DllClass () {} */ char AppName[] = "DLL Screen Tool"; char HelloMsg[] = "Hello, you're calling a function in this DLL"; char LoadMsg[] = "The DLL is loaded"; char UnloadMsg[] = "The DLL is unloaded"; char ThreadCreated[] = "A thread is created in this process"; char ThreadDestroyed[] = "A thread is destroyed in this process"; DllExport BOOL APIENTRY DllMain (HINSTANCE hInst /* Library instance handle. */ , DWORD reason /* Reason this function is being called. */ , LPVOID reserved /* Not used. */ ) { switch (reason) { case DLL_PROCESS_ATTACH: MessageBox (NULL, LoadMsg, AppName, MB_OK); break; case DLL_PROCESS_DETACH: MessageBox (NULL, UnloadMsg, AppName, MB_OK); break; case DLL_THREAD_ATTACH: MessageBox (NULL, ThreadCreated, AppName, MB_OK); break; case DLL_THREAD_DETACH: MessageBox (NULL, ThreadDestroyed, AppName, MB_OK); break; } /* Returns TRUE on success, FALSE on failure */ return TRUE; } DllExport void TestHello() { MessageBox (NULL, HelloMsg, AppName, MB_OK); }
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 #include <windows.h> #include <iostream> #include <fstream> #include <string> using namespace std; char LibName[] = "I:\\C\\HTMLActiveXTools\\Debug\\HTMLActiveXTools.dll"; char Hello[] = "TestHello"; char Text[] = "CHTMLTextBox50" ; char DllNotFound[] = "Cannot load library"; char AppName[] = "Load Library"; char HelloNotFound[] = "TestHello function not found"; char TextNotFound[] = "CHTMLTextBox50 function not found"; HINSTANCE hLib; FARPROC TestHelloAddr; FARPROC TestTextAddr; string HTMLLine; int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR CmdLine, int ShowLine) { hLib = LoadLibrary ((LPCTSTR)LibName); if (hLib==NULL) { MessageBox (NULL, DllNotFound, AppName, MB_OK); } else { TestHelloAddr = GetProcAddress (hLib, Hello); if (TestHelloAddr==NULL) { MessageBox (NULL, HelloNotFound, AppName, MB_OK); } else { TestHelloAddr(); // call [TestHelloAddr]; } // endif FreeLibrary (hLib); } // endif //ExitProcess (NULL); return 0; }
Partager