<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE></TITLE>
<META http-equiv=Content-Type content=text/html;charset=ISO-8859-1>
<META content="MSHTML 6.00.2900.2668" name=GENERATOR></HEAD>
<BODY text=#000000 bgColor=#ffffff>
<DIV><FONT face=Arial size=2>It's attached.&nbsp; Below are Rob's instructions 
for use.&nbsp; I found I had to add a dummy parameter in the method declarations 
otherwise the parameter values were shifted one to the right.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV>To use it, start by declaring data types for your function and method 
<BR>pointers:<BR><BR>type<BR>&nbsp;&nbsp; TConfigFunction = 
procedure(ParentWindow: HWnd); cdecl;<BR>&nbsp;&nbsp; TConfigMethod = 
procedure(ParentWindow: HWnd) of object; stdcall;<BR><BR>&nbsp;&nbsp; 
TCanWriteFunction = function: Integer; cdecl;<BR>&nbsp;&nbsp; TCanWriteMethod = 
function: Integer of object; stdcall;<BR><BR>The calling conventions differ on 
purpose. It just makes things a lot <BR>easier that way.<BR><BR>When you 
instantiate your object, call my MakeCdeclInstance function to <BR>create a 
wrapper for your method.<BR><BR>type<BR>&nbsp;&nbsp; TWinampPlugIn = 
class<BR>&nbsp;&nbsp; private<BR>&nbsp;&nbsp;&nbsp;&nbsp; FConfig: 
TConfigFunction;<BR>&nbsp;&nbsp;&nbsp;&nbsp; FCanWrite: 
TCanWriteFunction;<BR>&nbsp;&nbsp;&nbsp;&nbsp; procedure Config(ParentWindow: 
HWnd); stdcall;<BR>&nbsp;&nbsp;&nbsp;&nbsp; function CanWrite: Integer; 
stdcall;<BR>&nbsp;&nbsp; public<BR>&nbsp;&nbsp;&nbsp;&nbsp; constructor 
Create;<BR>&nbsp;&nbsp;&nbsp;&nbsp; destructor Destroy; 
override;<BR>&nbsp;&nbsp; end;<BR><BR>constructor 
TWinampPlugIn.Create;<BR>var<BR>&nbsp;&nbsp; Method: TMethod;<BR>&nbsp;&nbsp; 
ConfigMethod: TConfigMethod;<BR>&nbsp;&nbsp; CanWriteMethod: 
TCanWriteMethod;<BR>begin<BR>&nbsp;&nbsp; inherited;<BR>&nbsp;&nbsp; 
ConfigMethod := Config;<BR>&nbsp;&nbsp; Method := 
TMethod(ConfigMethod);<BR>&nbsp;&nbsp; FConfig := MakeCdeclInstance(Method, 
SizeOf(HWnd));<BR>&nbsp;&nbsp; CanWriteMethod := CanWrite;<BR>&nbsp;&nbsp; 
Method := TMethod(CanWriteMethod);<BR>&nbsp;&nbsp; FCanWrite := 
MakeCdeclInstance(Method, 0);<BR>end;<BR><BR>destructor 
TWinampPlugIn.Destroy;<BR>begin<BR>&nbsp;&nbsp; 
FreeCdeclInstance(@FCanWrite);<BR>&nbsp;&nbsp; 
FreeCdeclInstance(@FConfig);<BR>&nbsp;&nbsp; inherited;<BR>end;<BR><BR>After 
that, FConfig and FCanWrite are regular standalone-function <BR>pointers. When 
you or the DLL call them, though, they will call the <BR>corresponding method on 
a specific instance of the TWinampPlugIn class.</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<BLOCKQUOTE 
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=KyleyHarris@gmail.com href="mailto:KyleyHarris@gmail.com">Kyley 
  Harris</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> Monday, July 11, 2005 10:40 
PM</DIV>
  <DIV style="FONT: 10pt arial"><B>Subject:</B> [Spam] Re: [Spam] Re: [DUG] call 
  a method function from outside object</DIV>
  <DIV><BR></DIV>Yes, your interpretation of what I said is correct. The Call 
  Stack of the current executing thread would identify your callback routine, 
  then the proc in the dll calling it, and then the dll that is calling 
  it...<BR><BR>Probably don't need what rob did, but it certainly sounds curious 
  how he has tampered to get it work. Send the snip for R&amp;D value if you 
  don't mind.<BR><BR>Ross Levis wrote: 
  <BLOCKQUOTE cite=mid006a01c585fd$fb8a1d80$5100a8c0@levis4 type="cite">
    <META content="MSHTML 6.00.2900.2668" name=GENERATOR>
    <STYLE></STYLE>

    <DIV><FONT face=Arial size=2>Thanks for that.&nbsp; I think&nbsp;I 
    follow.&nbsp; Are you saying that the current DLL calling my procedure will 
    be&nbsp;in the process stack, but the other DLL in the 2nd component not 
    currently calling the&nbsp;procedure will not be in the stack?&nbsp; That 
    should work.&nbsp; But I won't need to do this now.</FONT></DIV>
    <DIV>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2>Rob Kennedy from an international mailing list 
    has just sent me&nbsp;a unit he&nbsp;wrote today&nbsp;which does exactly 
    what I need.&nbsp; It uses&nbsp;ASM code to fiddle things so that a call 
    made to a standard (cdecl) procedure address is converted to a method 
    call.&nbsp; I just implemented it and it works great!</FONT></DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2>I doubt anyone else would need such as thing 
    but I can pass it on if anyone is interested.</FONT></DIV>
    <DIV>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2>Regards,</FONT></DIV>
    <DIV><FONT face=Arial size=2>Ross.</FONT></DIV>
    <BLOCKQUOTE 
    style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: rgb(0,0,0) 2px solid; MARGIN-RIGHT: 0px">
      <DIV 
      style="FONT: 10pt arial; font-size-adjust: none; font-stretch: normal">----- 
      Original Message ----- </DIV>
      <DIV 
      style="BACKGROUND: rgb(228,228,228) 0% 50%; FONT: 10pt arial; font-size-adjust: none; font-stretch: normal; moz-background-clip: initial; moz-background-origin: initial; moz-background-inline-policy: initial"><B>From:</B> 
      <A title=KyleyHarris@gmail.com href="mailto:KyleyHarris@gmail.com">Kyley 
      Harris</A> </DIV>
      <DIV 
      style="FONT: 10pt arial; font-size-adjust: none; font-stretch: normal"><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; font-size-adjust: none; font-stretch: normal"><B>Sent:</B> 
      Monday, July 11, 2005 8:46 PM</DIV>
      <DIV 
      style="FONT: 10pt arial; font-size-adjust: none; font-stretch: normal"><B>Subject:</B> 
      [Spam] Re: [DUG] call a method function from outside object</DIV>
      <DIV><BR></DIV>If you want only one global callback for all dlls and all 
      instances of your component then you could do the following.<BR><BR>1/ 
      When your component is created and destroyed, add and remove it from an 
      internal TList or similar.<BR>2/ Each time you open a dll, bind it to the 
      same single callback which can do the following (psuedo code)<BR><BR>proc 
      GlobalOpen(bla1,bla2,bla3:integer)<BR>var<BR>&nbsp; 
      i:integer;<BR>&nbsp;DLLName:string;<BR>begin<BR>&nbsp; DLLNAme := 
      WalkCurrentProcessStackForDllName;<BR>&nbsp;{Doesn't have to go far 
      because this is always called from a dll}<BR>for i := 0 to _List.Count -1 
      do<BR>&nbsp; if _List[i].InterestedInDLL(DllName) then<BR>&nbsp; 
      _List[i].Open(bla1,bla2,bla3)<BR>end;<BR><BR>regards<BR>&nbsp; 
    Kyley</BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>