Re: How can I have a DLL write data to my application's form? (eg. DLLs and procedural type question)
From: Rob Kennedy (me3_at_privacy.net)
Date: 12/31/04
- Next message: Bob Richardson: "Re: Adding "Items" property to component"
- Previous message: jklimek_at_gmail.com: "How can I have a DLL write data to my application's form? (eg. DLLs and procedural type question)"
- In reply to: jklimek_at_gmail.com: "How can I have a DLL write data to my application's form? (eg. DLLs and procedural type question)"
- Next in thread: Jamie: "Re: How can I have a DLL write data to my application's form? (eg. DLLs and procedural type question)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Thu, 30 Dec 2004 17:19:05 -0600
jklimek@gmail.com wrote:
> // [FROM THE APPLICATION .EXE]
> type TStrProc = procedure(s : String);
Did you remember to use the ShareMem unit in both the DLL and the EXE?
There was a comment explaining that at the top of your new DLL project.
> type TProc = procedure(proc : TStrProc);
> var DllTest : TProc;
>
> // eg. load the library, etc, etc...
> // ...
>
> @DllTest := GetProcAddress(LibHandle, 'DllTest');
>
> // ...
> DllTest(@DisplayIt); // this should pass the address of my local
> procedure (DisplayIt) to the DLL.
Do you really mean *local* procedure? That's another name for a nested
procedure, and you're not allowed to use pointers to those since they
need to be called specially; the place you send the pointer won't know
how to call the nested procedure pointer.
> // [FROM THE DLL]
> type TProc = Procedure(s : String);
>
> // ...
> procedure DllTest(proc : TProc); stdcall;
A-ha. Here you've declared the procedure as stdcall. In your EXE, you
did not specify a calling convention, so Delphi assumed you wanted the
register calling convention. The two are not compatible. The
declarations of the functions in both modules need to match.
(It also helps your sanity if you use the same type names in both
places. You declared the callback function type as TProc in the DLL, but
you named it TStrProc in the EXE. Pick a real, meaningful name, and use
it throughout.)
-- Rob
- Next message: Bob Richardson: "Re: Adding "Items" property to component"
- Previous message: jklimek_at_gmail.com: "How can I have a DLL write data to my application's form? (eg. DLLs and procedural type question)"
- In reply to: jklimek_at_gmail.com: "How can I have a DLL write data to my application's form? (eg. DLLs and procedural type question)"
- Next in thread: Jamie: "Re: How can I have a DLL write data to my application's form? (eg. DLLs and procedural type question)"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|