How can I have a DLL write data to my application's form? (eg. DLLs and procedural type question)

jklimek_at_gmail.com
Date: 12/30/04


Date: 30 Dec 2004 13:14:16 -0800

I'm trying to have a DLL write to a Form from inside an application.
The way I'm trying to do this is by using a procedural type and then
passing it in as a variable to my DLL.

Here are some code snippets:

// [FROM THE APPLICATION .EXE]
type TStrProc = procedure(s : String);
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.

--------------

// [FROM THE DLL]
type TProc = Procedure(s : String);

// ...
procedure DllTest(proc : TProc); stdcall;
begin
proc('This should be displayed on my main application's form.');
end;

--------------

However, when I run this program I am getting an Access Violation
(Access Violation at address 008D1AA3. Write of address 0000000000.)
What am I doing wrong?

Thanks,
John



Relevant Pages

  • Re: How can I have a DLL write data to my applications form? (eg. DLLs and procedural type question)
    ... So are you saying that in my DLL I change this: ... type TProc = Procedure(s: String) stdcall; ... I'm a bit confused on how I use stdcall procedures from inside my ...
    (comp.lang.pascal.delphi.misc)
  • Re: Access Violation using CCriticalSection in DLL
    ... including the declarations of all variables involved ... precisely where does the access violation happen (it doesn't happen "in the DLL", ... When I Load a DLL (That I ... I pass the address of the log program by reference to the DLL. ...
    (microsoft.public.vc.mfc)
  • R e: Catching access violation exceptions
    ... >> exception handling support. ... >> option enables Microsoft's Structured Exception Handling in ... >> EH so that a catch will catch an access violation. ... least attempt to disable that DLL from being used the next time. ...
    (comp.lang.cpp)
  • Re: VerQueryValue() problem
    ... Do you get an access violation? ... > afterwards I query the version information of the DLL and I am running into> the problem, that VerQueryValue() fails on some systems and runs OK on> others for the same DLL. ... > My eMail-address has been changed due to spam. ...
    (microsoft.public.win2000.developer)
  • Re: Sockets in a DLL, access violation
    ... I don't believe it is a multiple thread problem. ... Jon Harris wrote: ... me the access violation, AFX_MANAGE_STATE is being executed. ... Have you added this code to the beginning of all our DLL exported functions? ...
    (microsoft.public.vc.mfc)