На главную

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 | Скачать Вниз

LoadLibrary



The LoadLibrary function maps the specified executable module into the address space of the calling process.

HINSTANCE LoadLibrary(

LPCTSTR lpLibFileName // address of filename of executable module
);


Parameters

lpLibFileName

Points to a null-terminated string that names the executable module (either a .DLL or .EXE file). The name specified is the filename of the module and is not related to the name stored in the library module itself, as specified by the LIBRARY keyword in the module-definition (.DEF) file.

If the string specifies a path but the file does not exist in the specified directory, the function fails.
If a path is not specified and the filename extension is omitted, the default library extension .DLL is appended. However, the filename string can include a trailing point character (.) to indicate that the module name has no extension. When no path is specified, the function searches for the file in the following sequence:

1. The directory from which the application loaded.
2. The current directory.
3. Windows 95: The Windows system directory. Use the GetSystemDirectory function to get the path of this directory.

Windows NT: The 32-bit Windows system directory. Use the GetSystemDirectory function to get the path of this directory. The name of this directory is SYSTEM32.

4. Windows NT: The 16-bit Windows system directory. There is no Win32 function that obtains the path of this directory, but it is searched. The name of this directory is SYSTEM.
5. The Windows directory. Use the GetWindowsDirectory function to get the path of this directory.
6. The directories that are listed in the PATH environment variable.



The first directory searched is the one directory containing the image file used to create the calling process (for more information, see the CreateProcess function). Doing this allows private dynamic-link library (DLL) files associated with a process to be found without adding the process's installed directory to the PATH environment variable.
Once the function obtains a fully qualified path to a library module file, the path is compared (case independently) to the full paths of library modules currently loaded into the calling process. These libraries include those loaded when the process was starting up as well as those previously loaded by LoadLibrary but not unloaded by FreeLibrary. If the path matches the path of an already loaded module, the function just increments the reference count for the module and returns the module handle for that library.



Return Values

If the function succeeds, the return value is a handle to the module.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.

Remarks

LoadLibrary can be used to map a DLL module and return a handle that can be used in GetProcAddress to get the address of a DLL function. LoadLibrary can also be used to map other executable modules. For example, the function can specify an .EXE file to get a handle that can be used in FindResource or LoadResource.
Module handles are not global or inheritable. A call to LoadLibrary by one process does not produce a handle that another process can use ѕ for example, in calling GetProcAddress. The other process must make its own call to LoadLibrary for the module before calling GetProcAddress.

If the module is a DLL not already mapped for the calling process, the system calls the DLL's DllEntryPoint function with the DLL_PROCESS_ATTACH value. If the DLL's entry-point function does not return TRUE, LoadLibrary fails and returns NULL.
Windows 95: If you are using LoadLibrary to load a module that contains a resource whose numeric identifier is greater than 0x7FFF, LoadLibrary fails.

See Also

DllEntryPoint, FindResource, FreeLibrary, GetProcAddress, GetSystemDirectory, GetWindowsDirectory, LoadResource


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

LoadLibrary



Функция LoadLibrary отображает определенный выполняемый модуль в пространство адреса вызова процесса.

HINSTANCE LoadLibrary(

АДРЕС LPCTSTR lpLibFileName // filename выполняемого модуля
);


Параметры

lpLibFileName

Точки на недействительный расторгнутую строку, которые называют выполняемый модуль (или .DLL или файл .EXE). Определенное имя является filename модуля и - не имело отношение к имени сохраненному в библиотечном модуле себя, как определено ключевым словом БИБЛИОТЕКИ в модульном-определении (.ОПРЕДЕЛЕННЫЙ) файл.

Если строка определяет путь но файл не существует в определенном директории, функция терпит неудачу.
Если путь не определен и расширение filename опущено, встроенное библиотечное расширение .DLL добавлено. Тем не менее, строка filename может включить конечный символ точки (.), чтобы указывать, что модульное имя не имеет расширение. Когда никакой путь не определен, функция ищет файл в следующей последовательности:

1. Директорий из которого приложение загружалось.
2. Текущий директорий.
3. Окно 95: системный директорий Окна. Используйте функцию GetSystemDirectory, чтобы получать путь этого директория.

Окно NT: системный директорий 32- битового Окна. Используйте функцию GetSystemDirectory, чтобы получать путь этого директория. Имя этого директория - SYSTEM32.

4. Окно NT: системный директорий 16- битового Окна. Нет функции Win32, что получает путь этого директория, но поискано. Имя этого директория СИСТЕМНОЕ.
5. Директорий Окна. Используйте функцию GetWindowsDirectory, чтобы получать путь этого директория.
6. Директории, которые указаны в переменной среды ПУТИ.



Поисканный первый директорий является одним директорием, содержащим файл образа использованный, чтобы создавать вызов процесса (более подробно, смотри функцию CreateProcess). Делая это допускает динамическую связь частной библиотеки (DLL) файлов связанную процессом, который нужно не обнаруживать добавляя включенный директорий процесса к переменной среды ПУТИ.
Как только функция получит полностью пригодный путь в библиотечный модульный файл, путь сравнен (случай независимо) в полные пути библиотечных модулей к настоящему времени загруженных на вызов процесса. Эти библиотеки включают те загруженные когда процесс запускал, а также те прежде загруженные LoadLibrary но не разгруженные FreeLibrary. Если путь соответствует пути уже загруженного модуля, функциональные точные приращения ссылка имеет значение модуль и возвращает модульную ручку для этой библиотеки.



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

Если функция добивается успеха, обратная величина является ручкой в модуль.
Если функция терпит неудачу, обратная величина НЕДЕЙСТВИТЕЛЬНА. Для того, чтобы расширять информацию ошибки, назовите GetLastError.

Замечания

LoadLibrary МОЖЕТ быть использован, чтобы отображать модуль DLL и возвращать ручку, которая может быть использована в GetProcAddress, чтобы получать адрес функции DLL. LoadLibrary МОЖЕТ также использован, чтобы отображать другие выполняемые модули. Например, функция может определить файл .EXE, чтобы получать ручку, которая может быть использована в FindResource или LoadResource.
Модульные ручки - не глобальный или inheritable. Вызов на LoadLibrary одним процессом не производит ручку, которую другой процесс может использовать U например, на вызове GetProcAddress. Другой процесс должен сделать своим собственным вызовом на LoadLibrary для модуля перед вызовом GetProcAddress.

Если модуль - DLL уже не отображенное для вызова процесса, системные вызовы функция DLL's DllEntryPoint с величиной DLL_PROCESS_ATTACH. Если вход-точка функции DLL's не возвращает ИСТИНА, LoadLibrary терпит неудачу и возвращает НЕДЕЙСТВИТЕЛЬНЫЙ.
Windows 95: Если Вы используете LoadLibrary, чтобы загружать модуль, который содержит ресурс, чей числовой идентификатор больше, чем 0x7FFF, LoadLibrary терпит неудачу.

Смотри Также

DllEntryPoint, FindResource, FreeLibrary, GetProcAddress, GetSystemDirectory, GetWindowsDirectory, LoadResource


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