Re: Calling procedure in a DLL



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


.



Relevant Pages

  • Re: using the CWegPage.dll
    ... It is using the WINAPI (_stdcall) calling ... > The source code for the DLL is on that page and is in this link to the zip ... >> change the calling convention to that which VB can handle. ... >>> The goal is to put an internet explorer web browswer on my form. ...
    (microsoft.public.vc.language)
  • Re: using the CWegPage.dll
    ... It is using the WINAPI (_stdcall) calling ... > The source code for the DLL is on that page and is in this link to the zip ... >> change the calling convention to that which VB can handle. ... >>> The goal is to put an internet explorer web browswer on my form. ...
    (microsoft.public.vb.winapi)
  • Re: How to export afunction in class?
    ... but I rarely find that I need stdcall when calling the exported functions of a DLL. ... I'll trade off performance vs. convenience at this level any time, ...
    (microsoft.public.vc.mfc)
  • Re: Possible causes of Err 483 "Cant find DLL entry point"?
    ... >Because of the underscore you will have to use the Declare Function ... It also appears the author is using _stdcall. ... confirms that the DLL was compiled as _stdcall (which is unsual, ... __stdcall calling convention." ...
    (microsoft.public.vb.general.discussion)
  • Re: Calling procedure in a DLL
    ... I'm experimenting with writing DLL's, but I get errors when calling the ... library TestLib; ... Real Programmers Do things like this. ...
    (alt.comp.lang.borland-delphi)