
13.08.2008, 22:46
|
Начинающий
|
|
Регистрация: 24.05.2008
Адрес: Москва
Сообщения: 133
Репутация: 15
|
|
Динамическая библиотека. Проблема загрузки.
Доброго всем настроения.
Народ помогите разораться в ошибке. Вроде как все правильно делаю.
вот исходники:
FunDll
Код:
library FunDll;
uses
SysUtils,
dialogs,
Classes;
{$R *.res}
procedure ShowMessage(text: string); stdcall; export;
begin
ShowMessage(text);
end;
function Summ(x: integer; y: integer):integer; stdcall; export;
begin
result:=x+y;
end;
exports
ShowMessage,
Summ;
end.
Prog
Код:
unit uProgMain;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TSumm = function (x: integer; y: integer ): integer;
TShowMgs = procedure (text: string);
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
const
s: string = 'Welcome';
var
dllHandle: THandle;
ShowMsg: TShowMgs;
begin
@ShowMsg:=nil;
dllHandle:=LoadLibrary('FunDll.dll');
if dllHandle=0 then
exit;
@ShowMsg:=GetProcAddress(dllHandle,'ShowMessage');
if @ShowMsg = nil then
exit;
// здесь пробывал задавать явно текст т.е. ShowMsg('Welcome');
ShowMsg(s);
FreeLibrary(dllHandle);
end;
end.
procedure TForm1.Button2Click(Sender: TObject);
var
dllHandle: THandle;
Sum: TSumm;
begin
@Sum:=nil;
dllHandle:=LoadLibrary('FunDll.dll');
if dllHandle=0 then
exit;
@Sum:=GetProcAddress(dllHandle,'Summ');
if @Summ = nil then
exit;
showmessage(inttostr(sum(4,6)));
FreeLibrary(dllHandle);
end;
end.
выдает ошибку  . Не могу понять в чем ошибка. по ходу ругается на переполнение Стека. Вроде все правильно делаю.
__________________
Програмист приходит на стрельбище. Стреляет. Прапор смотрит на мешень и говорит
Прапор: вы не попали ни один раз.
Программист: Пули вылетели, проблемы у вас.
|