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

Вниз

Вызов функций из DLL   Найти похожие ветки 

 
nikolo ©   (2002-08-09 17:26) [0]

Проблема в динамическом вызове функций из DLL с параметрами.

В "my_lib.dll" объявлены следующие функции:

Function Func_1: Integer; stdcall;
Begin
Result := 100;
End;

Function Func_2(Prm: Integer): Integer; stdcall;
Begin
if Prm = 1 then
Result := 100
else
Result := 200;
End;


В основной программе их вызываю так:

Function TForm1.Get_Result_1: Integer;
Var
DllHandle: THandle;
DllFuncName: Function: Integer;
Begin
@DllFuncName := nil;
DllHandle := LoadLibrary("my_lib.dll");
if DllHandle >= 32 then begin
@DllFuncName := GetProcAddress(DllHandle, "Func_1");
if @DllFuncName <> nil then
Result := DllFuncName
else
Result := -1;
end
else
Result := -2;
FreeLibrary(DllHandle);
End;

Function TForm1.Get_Result_2: Integer;
Var
DllHandle: THandle;
DllFuncName: Function(Prm: Integer): Integer;
Begin
@DllFuncName := nil;
DllHandle := LoadLibrary("my_lib.dll");
if DllHandle >= 32 then begin
@DllFuncName := GetProcAddress(DllHandle, "Func_2");
if @DllFuncName <> nil then
Result := DllFuncName(1)
else
Result := -1;
end
else
Result := -2;
FreeLibrary(DllHandle);
End;


Проблема в том, что в функция Get_Result_1 отрабатывает без проблем, а вот при выполнении функции Get_Result_2 на шаге Result := DllFuncName(1) происходит Access violation.
В чем проблема, подскажите пожалуйста!?


 
Ученик ©   (2002-08-09 17:31) [1]

Забыл stdcall


 
nikolo ©   (2002-08-09 17:34) [2]

Где?


 
Ученик ©   (2002-08-09 17:35) [3]

DllFuncName: Function(Prm: Integer): Integer; stdcall;


 
Skier ©   (2002-08-09 17:35) [4]

>nikolo
DllFuncName: Function(Prm: Integer): Integer; stdcall;


 
nikolo ©   (2002-08-09 17:46) [5]

Ну спасибо, выручили!



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

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

Наверх




Память: 0.47 MB
Время: 0.016 c
1-71162
Иван
2002-08-09 11:38
2002.08.22
Анализ строки


3-70966
ppcat
2002-07-30 14:10
2002.08.22
Доступ к документам Excell с помощью ADO или ODBC


4-71450
MJH
2002-06-17 18:18
2002.08.22
Крыса


1-71202
2snake
2002-08-10 12:11
2002.08.22
Сравнение дат.


3-70993
nikolo
2002-07-31 14:06
2002.08.22
Как в BDE создать алиас на MS SQL Server 2000?