<!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><FONT face=Arial size=2>Nevermind, I think I've worked it out! I was
doing it backwards. I should be defining a GetMyNumber function and then
assigning the address of my function to the DLL GetNumber function, so the DLL
knows where my function is located.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Cheers,</FONT></DIV>
<DIV><FONT face=Arial size=2>Ross.</FONT></DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=ross@stationplaylist.com href="mailto:ross@stationplaylist.com">Ross
Levis</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=delphi@ns3.123.co.nz
href="mailto:delphi@ns3.123.co.nz">NZ Borland Developers Group - Delphi
List</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Saturday, July 02, 2005 12:58
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> DLL's</DIV>
<DIV><FONT face=Arial size=2></FONT><BR></DIV>
<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></BLOCKQUOTE></BODY></HTML>