<!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. Below are Rob's instructions
for use. 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> </DIV>
<DIV>To use it, start by declaring data types for your function and method
<BR>pointers:<BR><BR>type<BR> TConfigFunction =
procedure(ParentWindow: HWnd); cdecl;<BR> TConfigMethod =
procedure(ParentWindow: HWnd) of object; stdcall;<BR><BR>
TCanWriteFunction = function: Integer; cdecl;<BR> 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> TWinampPlugIn =
class<BR> private<BR> FConfig:
TConfigFunction;<BR> FCanWrite:
TCanWriteFunction;<BR> procedure Config(ParentWindow:
HWnd); stdcall;<BR> function CanWrite: Integer;
stdcall;<BR> public<BR> constructor
Create;<BR> destructor Destroy;
override;<BR> end;<BR><BR>constructor
TWinampPlugIn.Create;<BR>var<BR> Method: TMethod;<BR>
ConfigMethod: TConfigMethod;<BR> CanWriteMethod:
TCanWriteMethod;<BR>begin<BR> inherited;<BR>
ConfigMethod := Config;<BR> Method :=
TMethod(ConfigMethod);<BR> FConfig := MakeCdeclInstance(Method,
SizeOf(HWnd));<BR> CanWriteMethod := CanWrite;<BR>
Method := TMethod(CanWriteMethod);<BR> FCanWrite :=
MakeCdeclInstance(Method, 0);<BR>end;<BR><BR>destructor
TWinampPlugIn.Destroy;<BR>begin<BR>
FreeCdeclInstance(@FCanWrite);<BR>
FreeCdeclInstance(@FConfig);<BR> 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> </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&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. I think I
follow. Are you saying that the current DLL calling my procedure will
be in the process stack, but the other DLL in the 2nd component not
currently calling the procedure will not be in the stack? That
should work. But I won't need to do this now.</FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2>Rob Kennedy from an international mailing list
has just sent me a unit he wrote today which does exactly
what I need. It uses ASM code to fiddle things so that a call
made to a standard (cdecl) procedure address is converted to a method
call. I just implemented it and it works great!</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </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> </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>
i:integer;<BR> DLLName:string;<BR>begin<BR> DLLNAme :=
WalkCurrentProcessStackForDllName;<BR> {Doesn't have to go far
because this is always called from a dll}<BR>for i := 0 to _List.Count -1
do<BR> if _List[i].InterestedInDLL(DllName) then<BR>
_List[i].Open(bla1,bla2,bla3)<BR>end;<BR><BR>regards<BR>
Kyley</BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>