<!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!&nbsp; I was 
doing it backwards.&nbsp; 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>&nbsp;</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.&nbsp; I've 
  successfully loaded the DLL and can call the functions &amp; 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>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>Here is an example DLL&nbsp;structure and what 
  I've done so far.</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</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>&nbsp; PSomeDLL = 
  ^TSomeDLL;</FONT></DIV><FONT color=#000080>&nbsp; TSomeDLL = 
  record<BR>&nbsp;&nbsp;&nbsp; Init : procedure; cdecl;<BR>&nbsp;&nbsp;&nbsp; 
  Quit : procedure; cdecl;<BR>&nbsp;&nbsp;&nbsp; GetNumber : 
  function(FileName:PChar):Integer; cdecl;<BR>&nbsp; end;</FONT></FONT></DIV>
  <DIV><FONT face=Arial color=#000080 size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial color=#000080 size=2>&nbsp; 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>&nbsp; DLLStruct: TDLLStruct;&nbsp; 
  </FONT></DIV>
  <DIV><FONT face=Arial color=#000080 size=2>begin</FONT></DIV>
  <DIV><FONT face=Arial color=#000080 size=2>&nbsp; @DLLStruct 
  :=&nbsp;GetProcAddress(...</FONT></DIV>
  <DIV><FONT face=Arial color=#000080 size=2>&nbsp; DLLStruct.Init;</FONT></DIV>
  <DIV><FONT face=Arial size=2>&nbsp; ...</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>This is working and I can&nbsp;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.&nbsp; How 
  do I go about that?</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</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>&nbsp;</DIV>
  <DIV><FONT face=Arial color=#000080 size=2>type</FONT></DIV>
  <DIV><FONT face=Arial size=2><FONT color=#000080>&nbsp; TGenNumber 
  =&nbsp;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>&nbsp; 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>&nbsp; Result := 1; // 
  something</FONT></DIV>
  <DIV><FONT face=Arial color=#000080 size=2>end;</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</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.&nbsp;&nbsp;It isn't being called within my program,&nbsp;the DLL will 
  be calling it, but the compiler doesn't know that.&nbsp; What as I 
  missing?</FONT></DIV>
  <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV><FONT face=Arial size=2>Thanks,</FONT></DIV>
  <DIV><FONT face=Arial size=2>Ross.</DIV></FONT></DIV></BLOCKQUOTE></BODY></HTML>