Many thanks Rob.  That sounds like what I'm after.

----- Original Message ----- 
From: "Rob Kennedy" <[EMAIL PROTECTED]>
To: "Borland's Delphi Discussion List" <[email protected]>
Sent: Monday, February 05, 2007 4:54 PM
Subject: Re: Window Handle from DLL Handle?


Ross Levis wrote:
> I'm wanting to find a window handle of a 3rd party DLL that I'm 
> loading
> via LoadLibrary.  It's possible that more than one instance of my
> program will be running on the same PC loading the same DLL, so I 
> can't
> use FindWindow based on the window name as there will be 2 or more
> found, and I don't know which one is which.  The DLL does not provide
> any handle details.

Call EnumWindows. For each window that _might_ be your target window
(matching title, class name, etc.), call GetWindowThreadProcessID. That
will give you the ID of the process that created the window. If that ID
matches the one you get from GetCurrentProcessID, then it's the window
created by your own program's copy of the DLL.

GetWindowModuleFileName might also help, but I don't know whether
"module" just means the EXE, or whether it will get you the DLL. At the
root, *all* windows are created by User32.dll.

-- 
Rob 

_______________________________________________
Delphi mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi

Reply via email to