This patch initializes the return buffer used in GetPrinterDriverA to
[wine.git] / documentation / internal-dll
blob6c37de0692a78a9d77a9a7a1cd9b9e298d0c0e28
1 This document describes some points you should know before implementing 
2 the internal counterparts to external DLL's. Only 32  bit DLL's
3 are considered.
5 1. The LibMain function
6 -----------------------
7 This is the way to do some initializing 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 then, 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 built-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 DLL and you the internal one. 
30 When you -as an example- fill an iconlist placed in the internal DLL the
31 application won't get the icons from the external DLL.
33 To work around this, you should always use a pointer to call such functions:
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>