Главная страница
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.048 c
14-1095848018
КаПиБаРа
2004-09-22 14:13
2004.10.10
Забавно


1-1096275024
Aleksandr.
2004-09-27 12:50
2004.10.10
Можно ли как-то оптимизировать этот код (для скорострельности)?


4-1094121621
Владимир
2004-09-02 14:40
2004.10.10
Как в одном приложении сделать окна (формы) доступные по Alt+Tab


4-1094549744
Multy
2004-09-07 13:35
2004.10.10
Как просмотреть список запушеных приложений?


3-1095173355
VictorT
2004-09-14 18:49
2004.10.10
MySQL 4.0.22 - он нормальный?