Top.Mail.Ru
Мастера DELPHI, Delphi programming community Титульная страница Поиск, карта сайта Написать письмо 
| Новости | Поиск | FAQ | Статьи | Книги | Новости VCL |
| Форумы ЧАТ | Орешник | KOL и MCK |
Форумы -» Основная («Начинающим»)/ Базы / WinAPI / Компоненты / Сети / Media / Игры / Corba и COM / KOL / FreePascal / .Net / Прочее / RSDN.ORG

« предыдущая ветвь | форум | следующая ветвь »

dll dynamik link [D7, WinXP]


Newad ©   (2004-09-22 00:57:00) 

проблема с динамич использованием

var
PRO:procedure(t:integer);
begin

d:=LoadLirary(...

PRO:=GetProcAddress(d,PCHAR(LongInt(1)));
PRO(456); =выдает ошибку Access violation с чего бы это?


GuAV   (2004-09-22 14:22:00) [1]


> Что не обязательно? ОБЯЗАТЕЛЬНО проверить и использовать
> одинаковое соглашение о вызове в DLL и в приложении, которое
> использует ресурсы DLL.

Да, но чтоб оно было cdecl или stdcall - не обязательно, resgiter тоже работает.


VMcL   (2004-09-22 11:19:00) [2]

>> Defunct ©  (22.09.04 01:10) [1]

Причем здесь имя? Он типа по номеру импортировать хочет, насколько понял. Только непонятно, зачем. Лучше по имени.

GetProcAddress

The GetProcAddress function retrieves the address of an exported function or variable from the specified dynamic-link library (DLL).

FARPROC GetProcAddress(
 HMODULE hModule,
 LPCSTR lpProcName
);

...

Remarks
The spelling and case of a function name pointed to by lpProcName must be identical to that in the EXPORTS statement of the source DLL's module-definition (.def) file. The exported names of functions may differ from the names you use when calling these functions in your code. This difference is hidden by macros used in the SDK header files. For more information, see Conventions for Function Prototypes.

The lpProcName parameter can identify the DLL function by specifying an ordinal value associated with the function in the EXPORTS statement. GetProcAddress verifies that the specified ordinal is in the range 1 through the highest ordinal value exported in the .def file. The function then uses the ordinal as an index to read the function's address from a function table. If the .def file does not number the functions consecutively from 1 to N (where N is the number of exported functions), an error can occur where GetProcAddress returns an invalid, non-NULL address, even though there is no function with the specified ordinal.

In cases where the function may not exist, the function should be specified by name rather than by ordinal value.


-SeM-   (2004-09-22 11:18:00) [3]

type TPRO = procedure(t: Integer);

var
 PRO: TPRO;


Newad   (2004-09-22 10:58:00) [4]

в длл обьявлено так
procedure ists(t:integer);
begin

end;

export
ists index 1,
....


Defunct   (2004-09-22 02:55:00) [5]

> не-а, не обязательно.

Что не обязательно? ОБЯЗАТЕЛЬНО проверить и использовать одинаковое соглашение о вызове в DLL и в приложении, которое использует ресурсы DLL.


GuAV   (2004-09-22 01:43:00) [6]


> первое:
>
> PRO:procedure(t:integer); stdcall/cdecl;

не-а, не обязательно.


Defunct   (2004-09-22 01:10:00) [7]

первое:

PRO:procedure(t:integer); stdcall/cdecl;

> PRO(456); =выдает ошибку Access violation с чего бы это?

PRO = nil, в dll нет функции с именем
HEX 00 00 00 01 00

FARPROC GetProcAddress(

   HMODULE hModule, // handle to DLL module  
   LPCSTR lpProcName // name of function
  );


Наверх

Титульная страница Поиск, карта сайта Написать письмо