На главную

On-line справка по Win32 API

Написать письмо
БЕСПЛАТНАЯ ежедневная online лотерея! Выигрывай каждый день БЕСПЛАТНО!
Список всех статей A-B-C-D-E-F-G-H-I-J-K-L-M-N-O-P-Q-R-S-T-U-V-W-X-Y-Z | Скачать Вниз

DllEntryPoint



The DllEntryPoint function is an optional method of entry into a dynamic-link library (DLL). If the function is used, it is called by the system when processes and threads are initialized and terminated, or upon calls to the LoadLibrary and FreeLibrary functions. DllEntryPoint is a placeholder for the library-defined function name. The actual name must be specified at build time. For more information, see the documentation included with your development tools.

BOOL WINAPI DllEntryPoint(

HINSTANCE hinstDLL, // handle to DLL module
DWORD fdwReason, // reason for calling function
LPVOID lpvReserved // reserved
);


Parameters

hinstDLL

A handle to the DLL. The value is the base address of the DLL. The HINSTANCE of a DLL is the same as the HMODULE of the DLL, so hinstDLL can be used in subsequent calls to the GetModuleFileName function and other functions that require a module handle.

fdwReason

Specifies a flag indicating why the DLL entry-point function is being called. This parameter can be one of the following values:

Value Meaning
DLL_PROCESS_ATTACH
Indicates that the DLL is attaching to the address space of the current process as a result of the process starting up or as a result of a call to LoadLibrary. DLLs can use this opportunity to initialize any instance data or to use the TlsAlloc function to allocate a thread local storage (TLS) index.
During initial process startup or after a call to LoadLibrary, the operating system scans the list of loaded DLLs for the process. For each DLL that has not already been called with the DLL_PROCESS_ATTACH value, the system calls the DLL's entry-point function. This call is made in the context of the thread that caused the process address space to change, such as the primary thread of the process or the thread that called LoadLibrary.
DLL_THREAD_ATTACH
Indicates that the current process is creating a new thread. When this occurs, the system calls the entry-point function of all DLLs currently attached to the process. The call is made in the context of the new thread. DLLs can use this opportunity to initialize a TLS slot for the thread. A thread calling the DLL entry-point function with the DLL_PROCESS_ATTACH value does not call the DLL entry-point function with the DLL_THREAD_ATTACH value.
Note that a DLL's entry-point function is called with this value only by threads created after the DLL is attached to the process. When a DLL is attached by LoadLibrary, existing threads do not call the entry-point function of the newly loaded DLL.
DLL_THREAD_DETACH
Indicates that a thread is exiting cleanly. If the DLL has stored a pointer to allocated memory in a TLS slot, it uses this opportunity to free the memory. The operating system calls the entry-point function of all currently loaded DLLs with this value. The call is made in the context of the exiting thread. There are cases in which the entry-point function is called for a terminating thread even if the DLL never attached to the thread ѕ for example, the entry-point function was never called with the DLL_THREAD_ATTACH value in the context of the thread in either of these two situations:· The thread was the initial thread in the process, so the system called the entry-point function with the DLL_PROCESS_ATTACH value. · The thread was already running when a call to the LoadLibrary function was made, so the system never called the entry-point function for it.


DLL_PROCESS_DETACH
Indicates that the DLL is detaching from the address space of the calling process as a result of either a clean process exit or of a call to FreeLibrary. The DLL can use this opportunity to call the TlsFree function to free any TLS indices allocated by using TlsAlloc and to free any thread local data. When a DLL detaches from a process as a result of process termination or as a result of a call to FreeLibrary, the operating system does not call the DLL's entry-point function with the DLL_THREAD_DETACH value for the individual threads of the process. The DLL is only given DLL_PROCESS_DETACH notification. DLLs can take this opportunity to clean up all resources for all threads attached and known to the DLL.


lpvReserved

Specifies further aspects of DLL initialization and cleanup.
If fdwReason is DLL_PROCESS_ATTACH, lpvReserved is NULL for dynamic loads and non-NULL for static loads.
If fdwReason is DLL_PROCESS_DETACH, lpvReserved is NULL if DllEntryPoint has been called by using FreeLibrary and non-NULL if DllEntryPoint has been called during process termination.



Return Values

When the system calls the DllEntryPoint function with the DLL_PROCESS_ATTACH value, the function returns TRUE if it succeeds or FALSE if initialization fails. If the return value is FALSE when DllEntryPoint is called because the process uses the LoadLibrary function, LoadLibrary returns NULL. If the return value is FALSE when DllEntryPoint is called during process initialization, the process terminates with an error. To get extended error information, call GetLastError.

When the system calls the DllEntryPoint function with any value other than DLL_PROCESS_ATTACH, the return value is ignored.

See Also

FreeLibrary, GetModuleFileName, LoadLibrary, TlsAlloc, TlsFree


Пригласи друзей и счет твоего мобильника всегда будет положительным!
Предыдущая статья
 
Сайт Народ.Ру Интернет
Следующая статья
Пригласи друзей и счет твоего мобильника всегда будет положительным!

DllEntryPoint



Функция DllEntryPoint является дополнительным методом входа на динамическую связь библиотеки (DLL). Если функция использована, она названа системой когда процессы и резьба инициализированы и завершены, или на вызовах в LoadLibrary и функции FreeLibrary. DllEntryPoint - метка-заполнитель для определенного библиотечного функционального имени. Фактическое имя должно быть определено в строить время. Более подробно, смотри документацию включенную вашими инструментальными средствами разработки.

BOOL WINAPI DllEntryPoint(

HINSTANCE hinstDLL, // РУЧКА в модуль DLL DWORD fdwReason, // причина вызова функции LPVOID lpvReserved // зарезервированное
);


Параметры

hinstDLL

Ручка на DLL. Величина является базовым адресом DLL. HINSTANCE DLL Такой же как и HMODULE DLL, так что hinstDLL может быть использован на последующих вызовах в функцию GetModuleFileName и другие функции, которые требуют модульную ручку.

fdwReason

Определяет флаг, указывающий почему вход-точка функции DLL назваться. Этот параметр может быть одним из следующего величин:

Оцените Значение DLL_PROCESS_ATTACH
Указывает, что DLL подключается по пространству адреса текущего процесса в результате пуска процесса или в результате вызова на LoadLibrary. DLLs МОЖЕТ использовать эту возможность инициализировать любые данные примера или, чтобы использовать функцию TlsAlloc, чтобы распределять локальную память резьбы (TLS) индекса.
В течение начального запуска процесса или после вызова на LoadLibrary, операционная система сканирует список загруженных DLLs для процесса. Для каждого DLL, что уже не назван величиной DLL_PROCESS_ATTACH, система называет вход-точку функции DLL's. Этот вызов сделан в контексте резьбы, которая заставляла пространство адреса процесса, чтобы изменять, как например, первичная резьба процесса или резьба, что назвавшее LoadLibrary.
DLL_THREAD_ATTACH
Указывает, что текущий процесс создает новую резьбу. Когда это происходит, система называет вход-точку функции всех DLLs к настоящему времени приложенной к процессу. Вызов сделан в контексте новой резьбы. DLLs МОЖЕТ использовать эту возможность инициализировать слот TLS для резьбы. Резьба, вызывающая вход-точку функции DLL с величиной DLL_PROCESS_ATTACH не называет вход-точку функции DLL с величиной DLL_THREAD_ATTACH.
Отметьте, что вход-точка функции DLL's назван этой величиной только резьбой созданной после того, как DLL будет приложен к процессу. Когда DLL приложен LoadLibrary, существующий резьба не называет вход-точку функции вновь загруженного DLL.
DLL_THREAD_DETACH
Указывает, что резьба выходит из чисто. Если DLL загрузил бы указатель на распределившее память в слоте TLS, это использует эту возможность освобождать память. Операционная система называет вход-точку функции их к настоящему времени загрузившее DLLs с этой величиной. Вызов сделан в контексте выхода резьбы. Есть случаи в которых вход-точка функции назван к завершению резьбы даже если бы DLL никогда не прилаганное к резьбе U например, вход-точка функции никогда не был называн величиной DLL_THREAD_ATTACH в контексте резьбы в любой из этих двух ситуаций: резьба была начальной резьбой в процессе, так что система была названа вход-точка функции с DLL_PROCESS_ATTACH value. резьба уже работала когда вызов в функцию LoadLibrary был сделан, так что система никогда не была называна вход-точка функции к этому.


DLL_PROCESS_DETACH
Указывает, что DLL отделяется из пространства адреса вызова процесса в результате или чистый выход процесса или вызова на FreeLibrary. DLL Может использовать эту возможность называть функцию TlsFree, чтобы освобождать любые индексы TLS распределенные использованием TlsAlloc и, чтобы освобождать любые локальные данные резьбы. Когда DLL отделяется из процесса в результате завершения процесса или в результате вызова на FreeLibrary, операционная система не называет вход-точку функции DLL's с величиной DLL_THREAD_DETACH для индивидуальной резьбы процесса. DLL Только дан уведомление DLL_PROCESS_DETACH. DLLs МОЖЕТ взять эту возможность наводить порядок все ресурсы для всей резьбы приложенной и узнанной на DLL.


lpvReserved

Определяет дальнейшие аспекты инициализации DLL и очистка.
Если fdwReason - DLL_PROCESS_ATTACH, lpvReserved НЕДЕЙСТВИТЕЛЬНО для динамической загрузки и не-НЕДЕЙСТВИТЕЛЬНЫЙ для статической загрузки.
Если fdwReason - DLL_PROCESS_DETACH, lpvReserved НЕДЕЙСТВИТЕЛЬНО если DllEntryPoint назван использованием FreeLibrary и не-НЕДЕЙСТВИТЕЛЬНЫЙ если DllEntryPoint назван в течение завершения процесса.



Обратные Величины

Когда система называет функцию DllEntryPoint с величиной DLL_PROCESS_ATTACH, функция возвращает ИСТИНУ если она получает или ЛОЖЬ если инициализация терпит неудачу. Если обратная величина является ЛОЖЬЮ когда DllEntryPoint назван поскольку процесс использует функцию LoadLibrary, возврат LoadLibrary НЕДЕЙСТВИТЕЛЬНЫЙ. Если обратная величина является ЛОЖЬЮ когда DllEntryPoint назван в течение инициализации процесса, процесс завершается с ошибкой. Для того, чтобы расширять информацию ошибки, назовите GetLastError.

Когда система называет функцию DllEntryPoint с любой величиной кроме DLL_PROCESS_ATTACH, обратная величина проигнорирована.

Смотри Также

FreeLibrary, GetModuleFileName, LoadLibrary, TlsAlloc, TlsFree


Вверх Version 1.3, Oct 26 2010 © 2007, 2010, mrhx Вверх
 mrhx software  Русский перевод OpenGL  Русский перевод Win32 API
 
Используются технологии uCoz