Re: Calling procedure in a DLL
- From: erewhon@xxxxxxxxxx (J French)
- Date: Tue, 7 Feb 2006 15:37:32 +0000 (UTC)
Look inline
On Tue, 07 Feb 2006 13:35:22 GMT, "Carl Willems" <noreply@xxxxxxxxxx>
wrote:
Hello,
I'm experimenting with writing DLL's, but I get errors when calling the
functions that I wrote.
The library looks like:
library TestLib;
uses
ShareMem,
SysUtils,
Classes,
Dialogs,
Procedure Test(Const Value : integer);stdcall;
begin
MessageDlg(IntToStr(Value),mtInformation,[mbOK],0);
end;
exports
Test;
begin
end.
I compiled and saved in system32 in the Windows folder.
I have declared following function in a program:
Procedure Test(Const Value : integer);External 'TestLib.dll';
And where is that told to use StdCall ?
More follows
Then I call the procedure by
procedure TfrmMain.Test1Click(Sender: TObject);
begin
test(5);
end;
The messagbox that appears shows "471526" rather than "5". I tried with
strings as well, doesn't work neither.
Anybody any idea's ?
Do not, ever, use Sharemem, just do not do it.
If you want to know why, then it is because it stops your DLL being
stand-alone, it makes it rely on another DLL (or is it a hookup) which
will probably not be there with 'C' or VB
Anyway, you are sending stuff as StdCall and getting at it as the
Delphi default which is Register
.
- Follow-Ups:
- Re: Calling procedure in a DLL
- From: Maarten Wiltink
- Re: Calling procedure in a DLL
- References:
- Calling procedure in a DLL
- From: Carl Willems
- Calling procedure in a DLL
- Prev by Date: Re: Calling procedure in a DLL
- Next by Date: Re: Calling procedure in a DLL
- Previous by thread: Re: Calling procedure in a DLL
- Next by thread: Re: Calling procedure in a DLL
- Index(es):
Relevant Pages
|