Added a few authors.
[wine/multimedia.git] / documentation / internal-dll
blobd90b70b18e5e6cb2d6f51649a94e678d347230a8
1 This document describes some points you should know when you are going to
2 implement the internal counterparts to external DLL's. Only 32  bit DLL's
3 are considered.
5 1. The LibMain function
6 -----------------------
7 These are the way to do some initialising when a process or thread is attached
8 to the dll. The function name is taken from a *.spec file line:
10 init    YourFunctionName
12 the you have to implement the function:
15 BOOL32 WINAPI YourLibMain(HINSTANCE32 hinstDLL,
16                          DWORD fdwReason, LPVOID lpvReserved)
17 { if (fdwReason==DLL_PROCESS_ATTACH)
18   { ...
19   } 
20   ....
24 2. Using functions from other build-in DLL's
25 --------------------------------------------
26 The problem here is, that you can't know if you have to call the function from
27 the internal or the external DLL. If you just call the function you will get
28 the internal implementation. If the external DLL is loaded the executed program
29 will use the external and you the internal DLL. 
30 When you -as example- fill a iconlist placed in the internal DLL the
31 application wont get the icons from the external DLL.
33 To go around this you have to call the functions over pointer.
35 /* definition of the pointer type*/
36 void (CALLBACK* pDLLInitComctl)();
38 /* getting the function address  this should be done in the
39  LibMain function when called with DLL_PROCESS_ATTACH*/
41 BOOL32 WINAPI Shell32LibMain(HINSTANCE32 hinstDLL, DWORD fdwReason,
42                                                          LPVOID lpvReserved)
43 { HINSTANCE32 hComctl32;
44   if (fdwReason==DLL_PROCESS_ATTACH)
45   { /* load the external / internal DLL*/
46     hComctl32 = LoadLibrary32A("COMCTL32.DLL"); 
47     if (hComctl32)
48     { /* get the function pointer */
49       pDLLInitComctl=GetProcAddress32(hComctl32,"InitCommonControlsEx");
51           /* check it */
52       if (pDLLInitComctl)
53       { /* use it */
54         pDLLInitComctl();
55       }
56       
57       /* free the DLL / decrease the ref count */
58       FreeLibrary32(hComctl32);
59     }
60     else
61     { /* do some panic*/
62       ERR(shell,"P A N I C error getting functionpointers\n");
63       exit (1);
64     }
65   }
66  ....
68 3. Getting resources from a *.rc file linked to the DLL
69 -------------------------------------------------------
70 < If you know how, write some lines>
74 ----------
75 <juergen.schmied@metronet.de>