Главная страница
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.039 c
1-1095780562
B-boy Dimo-N
2004-09-21 19:29
2004.10.10
детская проблема с компилированием DLL


1-1096129696
AdmeraL
2004-09-25 20:28
2004.10.10
копирование файлов


3-1095266849
dumitru
2004-09-15 20:47
2004.10.10
Range...


1-1096025332
SergeyM
2004-09-24 15:28
2004.10.10
Текст в формате HTML


8-1089992678
^FH^
2004-07-16 19:44
2004.10.10
размер файла JPEG