Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2004.10.10;
Скачать: CL | DM;

Вниз

dll dynamik link   Найти похожие ветки 

 
Newad   (2004-09-22 00:57) [0]

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

var
PRO:procedure(t:integer);
begin

d:=LoadLirary(...

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


 
Defunct ©   (2004-09-22 01:10) [1]

первое:

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
  );


 
GuAV ©   (2004-09-22 01:43) [2]


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

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


 
Defunct ©   (2004-09-22 02:55) [3]

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

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


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

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

end;

export
ists index 1,
....


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

type TPRO = procedure(t: Integer);

var
 PRO: TPRO;


 
VMcL ©   (2004-09-22 11:19) [6]

>>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.


 
GuAV ©   (2004-09-22 14:22) [7]


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

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



Страницы: 1 вся ветка

Текущий архив: 2004.10.10;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.044 c
3-1095321996
Domkrat
2004-09-16 12:06
2004.10.10
Create database


1-1095976334
Ezhik
2004-09-24 01:52
2004.10.10
Поиск файлов


1-1095413767
Ms.Dunkul
2004-09-17 13:36
2004.10.10
height


4-1094730245
FGH
2004-09-09 15:44
2004.10.10
Debug API


14-1095840635
kaZaNoVa
2004-09-22 12:10
2004.10.10
2 Системы или Защита/изменение файлов и Реестра.