<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2668" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV>
<DIV><FONT face=Arial size=2>I have a DLL which defines a structure for passing
information 2 ways.</FONT></DIV>
<DIV><FONT face=Arial size=2>I need to define some functions and procedures that
will be called from a 3rd party DLL that I'm loading. I've successfully
loaded the DLL and can call the functions & procedures in the DLL, but I'm
not sure how to set up the reverse situation where the DLL requests information
from my program.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Here is an example DLL structure and what I've
done so far.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial color=#000080 size=2>type</FONT></DIV>
<DIV><FONT face=Arial size=2>
<DIV><FONT face=Arial color=#000080 size=2> PSomeDLL =
^TSomeDLL;</FONT></DIV><FONT color=#000080> TSomeDLL =
record<BR> Init : procedure; cdecl;<BR> Quit
: procedure; cdecl;<BR> GetNumber :
function(FileName:PChar):Integer; cdecl;<BR> end;</FONT></FONT></DIV>
<DIV><FONT face=Arial color=#000080 size=2></FONT> </DIV>
<DIV><FONT face=Arial color=#000080 size=2> TDLLStruct = function:
PSomeDLL; cdecl;<BR>....</FONT></DIV>
<DIV><FONT face=Arial color=#000080 size=2>var</FONT></DIV>
<DIV><FONT face=Arial color=#000080 size=2> DLLStruct: TDLLStruct;
</FONT></DIV>
<DIV><FONT face=Arial color=#000080 size=2>begin</FONT></DIV>
<DIV><FONT face=Arial color=#000080 size=2> @DLLStruct
:= GetProcAddress(...</FONT></DIV>
<DIV><FONT face=Arial color=#000080 size=2> DLLStruct.Init;</FONT></DIV>
<DIV><FONT face=Arial size=2> ...</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>This is working and I can successfully call
DLLStruct.Init and DLLStruct.Quit from my program, but GetNumber is actually
called by the DLL, so I need to supply the result of the function. How do
I go about that?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I thought I would have to do something like
this:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial color=#000080 size=2>type</FONT></DIV>
<DIV><FONT face=Arial size=2><FONT color=#000080> TGenNumber
= function(FileName:PChar):Integer; cdecl;<BR></FONT></DIV></FONT>
<DIV><FONT face=Arial color=#000080 size=2>var</FONT></DIV>
<DIV><FONT face=Arial color=#000080 size=2> GetGenNumber:
TGenNumber;</FONT></DIV>
<DIV><FONT face=Arial color=#000080 size=2>...</FONT></DIV>
<DIV><FONT face=Arial color=#000080 size=2>GetGenNumber :=
DLLStruct.GetNumber;</FONT></DIV>
<DIV><FONT face=Arial color=#000080 size=2>...</FONT></DIV>
<DIV><FONT face=Arial color=#000080 size=2>function
GetGenNumber(FileName:PChar):Integer;</FONT></DIV>
<DIV><FONT face=Arial color=#000080 size=2> Result := 1; //
something</FONT></DIV>
<DIV><FONT face=Arial color=#000080 size=2>end;</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>This compiles but the function GetGenNumber above
is not compiled into my executable because it doesn't think it's being
called. It isn't being called within my program, the DLL will be
calling it, but the compiler doesn't know that. What as I
missing?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Thanks,</FONT></DIV>
<DIV><FONT face=Arial size=2>Ross.</DIV></FONT></DIV></BODY></HTML>