|
Run-Time Dynamic Linking
When the application calls the LoadLibrary or LoadLibraryEx functions, the system attempts to locate the DLL using the same search
sequence used in load-time dynamic linking (see Load-Time Dynamic Linking). If the search succeeds, the system maps the DLL module into the virtual
address space of the process and increments the reference count. If the call to LoadLibrary or LoadLibraryEx specifies a DLL whose code is already mapped into the virtual address space
of the calling process, the function simply returns a handle to the DLL and
increments the DLL reference count. Note that two DLLs that have the same base
filename and extension but are found in different directories are not considered to
be the same DLL.
The operating system calls the entry-point function in the context of the
thread that called LoadLibrary or LoadLibraryEx. The entry-point function is not called if the DLL was already loaded by the
process through a call to LoadLibrary or LoadLibraryEx with no corresponding call to the FreeLibrary function.
If the system cannot find the DLL or if the entry-point function returns
FALSE, LoadLibrary or LoadLibraryEx returns NULL. If LoadLibrary or LoadLibraryEx succeeds, it returns a handle of the DLL module. The process can use this
handle to identify the DLL in a call to the GetProcAddress, FreeLibrary, or FreeLibraryAndExitThread function.
The GetModuleHandle function returns a handle used in GetProcAddress, FreeLibrary, or FreeLibraryAndExitThread. The GetModuleHandle function succeeds only if the DLL module is already mapped into the address
space of the process by load-time linking or by a previous call to LoadLibrary or LoadLibraryEx. Unlike LoadLibrary or LoadLibraryEx, GetModuleHandle does not increment the module reference count. The GetModuleFileName function retrieves the full path of the module associated with a handle
returned by GetModuleHandle, LoadLibrary, or LoadLibraryEx.
The process can use GetProcAddress to get the address of an exported function in the DLL using a DLL module
handle returned by either LoadLibrary, LoadLibraryEx, or GetModuleHandle.
When the DLL module is no longer needed, the process can call FreeLibrary or FreeLibraryAndExitThread. These functions decrement the module reference count and unmap the DLL code
from the virtual address space of the process if the reference count is zero.
Run-time dynamic linking enables the process to continue running even if a DLL
is not available. The process can then use an alternate method to accomplish
its objective. For example, if a process is unable to locate one DLL, it can try
to use another, or it can notify the user of an error. If the user can provide
the full path of the missing DLL, the process can use this information to load
the DLL even though it is not in the normal search path. This situation
contrasts with load-time linking, in which the operating system simply terminates the
process if it cannot find the DLL.
Run-time dynamic linking can cause problems if the DLL uses the DllEntryPoint function to perform initialization for each thread of a process, because the
entry-point is not called for threads that existed before LoadLibrary or LoadLibraryEx is called. For an example showing how to deal with this problem, see Using Thread Local Storage in a Dynamic-Link Library.
| Last news from Greatis Software |
 |
|
Nostalgia .Net |
|
.Net is powerful, but not all-powerful, so sometimes we need to use Win32 API for our .Net applications. It's simple enough with Platform Invoke if you have Win32 skill, but we do not always have time to dig the ancient documentation, declare the special types that are compatible with Win32, find the values of the Win32's constants and so on. Nostalgia .Net offers several simple-to-use classes, and components that will allow you to forget about the headache of Win32 and just use the power of Win32 in your application the same way as you use the native. Net classes. More » |
| Recommended software for developers |
 |
|
Ultimate Pack |
|
Component pack for Delphi and C++ Builder that contains runtime form designer, runtime object inspector, print suite and much more for the very special price. More » |
 |
|
Form Designer .Net |
|
Unique runtime form design solution that allows to edit any form in .Net WinForms application at runtime with full source codes for only 300 euro! More » |
 |
|
Print Suite .Net |
|
Print Suite .Net is a set of components for easy printing texts, images and grids from your WinForms applications. Full C# source codes are available More » |
 |
|
Gradient Controls .Net |
|
Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available More » |
 |
|
Greatis iGrid |
|
iGrid plots drawing grid right over your desktop, so you can use it everywhere, with any drawing application without any special plugins for different graphic editors. More » |
All the contacts and projectsDmitry Vasiliev (just.dmitry)
Related LinksSoftware for Visual Studio .NET developers Software for Delphi and C++ Builder developers Software for Visual Basic 6 developers Delphi Tips&Tricks MegaDetailed.NET More Online Helps Win32 Programmer's Reference Win32 Multimedia Programmer's Reference OLE Programmer's Reference Microsoft Windows Pen API Programmer's Reference Microsoft Windows Sockets 2 Reference Microsoft Windows Telephony API (TAPI) Programmer's Reference Unix Manual Pages
|