Newsgroups : Borland : borland.public.delphi.nativeapi.win32 : 2007 Aug : Handle of the Caller

www.cryer.info
Managed Newsgroup Archive

Handle of the Caller

Subject:Handle of the Caller
Posted by:"Churc" (cebas..@gmail.com)
Date:8 Aug 2007 13:22:01

Hello,

How can i get the handle of the caller of a function?

What im doing, many ppl is helping me here, i tried in different
methods to do a Plugin Framework, i started with COM Object, but
looking for others advanced Plugin Framework codes, i saw something
very simple and more efficient...

Example

### EXE

//Here a example of record where i pass to the DLLs
  _TAG_MY_LINK = packed record
    //WOW thanks for explain to me about cbSize :D
    cbSize: DWORD;
    FooFunc: Function (Foo: Integer): Integer; StdCall;
  end;
  TMyLink = _TAG_MY_LINK;
  PMyLink = ^TMyLink;


var
  MyLink: TMyLink;


Function _Foo(Foo: Integer): Integer; StdCall;
var
  hCaller: THandle;
begin
  //How can i get the handle of the caller, since many DLLs can
  //call this function?!? its possible?
  hCaller := =(
  //Getting the Handle of the Caller i can manage my plugins :D
end;


//Here i pass to a DLL the Link Struct, then it can call this function
//outside this process

Procedure PasstoDLL;
var
  hHandle: THandle;
begin
  hHandle := LoadLibr....
  {...}
  DLLReceiveit(@MyLink);
  {...}
end;


initialization
begin
  FillChar(MyLink, SizeOf(TMyLink), 0);
  with MyLink do
  begin
    cbSize := SizeOf(TMyLink);
    FooFunc := @_Foo;
  end;
end;


### DLL

var
  Link: TMyLink;

Function DLLReceiveit(TheLink: PMyLink): BOOL; StdCall;
begin
  Link := TheLink^;
  //Here i called the _Foo Function in EXE, but in EXE how can
  //i get the Handle of the Caller, since more than one DLL will
  //call that function?
  Link.Foo(1);
end;

Sorry for my bad english ;

And thanks for help :D

Best Regards,
Carlos


--

Replies:

www.cryer.info
Managed Newsgroup Archive