mirror of
git://source.winehq.org/git/wine.git
synced 2024-10-31 10:41:12 +00:00
75 lines
2.2 KiB
Text
75 lines
2.2 KiB
Text
This document describes some points you should know before implementing
|
|
the internal counterparts to external DLL's. Only 32 bit DLL's
|
|
are considered.
|
|
|
|
1. The LibMain function
|
|
-----------------------
|
|
This is the way to do some initializing when a process or thread is attached
|
|
to the dll. The function name is taken from a *.spec file line:
|
|
|
|
init YourFunctionName
|
|
|
|
then, you have to implement the function:
|
|
|
|
|
|
BOOL32 WINAPI YourLibMain(HINSTANCE32 hinstDLL,
|
|
DWORD fdwReason, LPVOID lpvReserved)
|
|
{ if (fdwReason==DLL_PROCESS_ATTACH)
|
|
{ ...
|
|
}
|
|
....
|
|
}
|
|
|
|
|
|
2. Using functions from other built-in DLL's
|
|
--------------------------------------------
|
|
The problem here is, that you can't know if you have to call the function from
|
|
the internal or the external DLL. If you just call the function you will get
|
|
the internal implementation. If the external DLL is loaded the executed program
|
|
will use the external DLL and you the internal one.
|
|
When you -as an example- fill an iconlist placed in the internal DLL the
|
|
application won't get the icons from the external DLL.
|
|
|
|
To work around this, you should always use a pointer to call such functions:
|
|
|
|
/* definition of the pointer type*/
|
|
void (CALLBACK* pDLLInitComctl)();
|
|
|
|
/* getting the function address this should be done in the
|
|
LibMain function when called with DLL_PROCESS_ATTACH*/
|
|
|
|
BOOL32 WINAPI Shell32LibMain(HINSTANCE32 hinstDLL, DWORD fdwReason,
|
|
LPVOID lpvReserved)
|
|
{ HINSTANCE32 hComctl32;
|
|
if (fdwReason==DLL_PROCESS_ATTACH)
|
|
{ /* load the external / internal DLL*/
|
|
hComctl32 = LoadLibrary32A("COMCTL32.DLL");
|
|
if (hComctl32)
|
|
{ /* get the function pointer */
|
|
pDLLInitComctl=GetProcAddress32(hComctl32,"InitCommonControlsEx");
|
|
|
|
/* check it */
|
|
if (pDLLInitComctl)
|
|
{ /* use it */
|
|
pDLLInitComctl();
|
|
}
|
|
|
|
/* free the DLL / decrease the ref count */
|
|
FreeLibrary32(hComctl32);
|
|
}
|
|
else
|
|
{ /* do some panic*/
|
|
ERR(shell,"P A N I C error getting functionpointers\n");
|
|
exit (1);
|
|
}
|
|
}
|
|
....
|
|
|
|
3. Getting resources from a *.rc file linked to the DLL
|
|
-------------------------------------------------------
|
|
< If you know how, write some lines>
|
|
|
|
|
|
|
|
----------
|
|
<juergen.schmied@metronet.de>
|