Главная страница
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.017 c
1-71077
Елена
2002-08-12 06:38
2002.08.22
Цвет фона для OleContainer


7-71399
Groove
2002-06-09 12:08
2002.08.22
Как выключить комп


14-71321
jessis
2002-07-26 15:22
2002.08.22
Компиляция


1-71213
[BAD]Angel
2002-08-10 12:56
2002.08.22
Есть ли такая возможность в Delphi?


4-71431
IKarikh
2002-06-19 18:28
2002.08.22
Мьютексы