Board index » delphi » Help: getting Application.Handle inside a DLL?

Help: getting Application.Handle inside a DLL?

Hi to you all,

Could anyone tell me how to obtain the handle of the application
(Application.Handle) owning
a DLL inside of the DLL? That is, I'm writing a multi-purpose DLL
containing its own top-level windows which need to be owned by an
application in order to be minimized etc together with this app. Of
course I could write a proc inside the DLL assigning the application's
handle to the DLL handle:

<<inside DLL>>
Procedure SetHandle(H: WHND); Export;
Begin   Application.Handle:=H End;

...rest of DLL code
<<>>

Calling this from the application would solve the problem. For me this
doesn't work, though, I need to find out the Application.handle without
having the application pasing it to the DLL.

Can anyone help me out?

Thanx, Han

 

Re:Help: getting Application.Handle inside a DLL?


Hmmmmmm..........  Tricky, as it is possible that several applications can
all access a single DLL
at the same time.
It would be better for the DLL to obtain this information, and there are
several functions that will do it.
I can't remember the exact name (there are different version for Win NT and
Win 9*), but it is something like
GetModuleInfo32 which gets info on all loaded DLL's and app's that reference
them. Try looking up MODULE in the on-line help for a fuller explanation.

Re:Help: getting Application.Handle inside a DLL?


Hi,

Thanx! I'll try this.
PS: Different applics can access a DLL but will load it in their own
separate mem space (at least the data-portion)?

Han

Quote
Dave Derrick wrote:

> Hmmmmmm..........  Tricky, as it is possible that several applications can
> all access a single DLL
> at the same time.
> It would be better for the DLL to obtain this information, and there are
> several functions that will do it.
> I can't remember the exact name (there are different version for Win NT and
> Win 9*), but it is something like
> GetModuleInfo32 which gets info on all loaded DLL's and app's that reference
> them. Try looking up MODULE in the on-line help for a fuller explanation.

Re:Help: getting Application.Handle inside a DLL?


Win32 provides a mechanism (see "DLLEntryPoint" in the Win32 help file)
where it will call a routine in the DLL each time a process or thread
attaches to the DLL.

Delphi surfaces that interface through the "DLLProc" procedure variable.

These provide the means to realize when a DLL is being attached or
detached, and by whom, without being told by the clients.

Other Threads