Window caption from hmodule.

  • Thread starter Thread starter Abhishek
  • Start date Start date
A

Abhishek

Hi,

How do i find the window caption by using the hmodule of that window?

Regards
Abhishek
 
Abhishek said:
How do i find the window caption by using the hmodule of that window?

You don't because there may be multiple such windows.

Regards,
Will
 
Hi William
Thanks a lot for replying.

you dont or you cant? sorry noob here. there will always be only one
instance of this window running.

regards
Abhishek
 
Abhishek said:
you dont or you cant? sorry noob here. there will always be only one
instance of this window running.

It's one of those "undecidable" propositions.

Assuming you have an module handle, you could call EnumWindows(). For each
window returned call GetWindowLong(hwnd, GWL_HINSTANCE). Compare what is
returned to the module handle you have. Take those windows where you have a
match. You may get 0, 1, or more matches.

BTW, how did you get the module handle and what else do you know of the
window in question?

Regards,
Will
 
Hi William
firstly thanks for replying,

I have a dll that is being called by an app, the application may change but
my dll will always be called since it is a system wide hook. I need to know
the window caption of the app that loaded my dll.

Regards
Abhi
 
Abhishek said:
firstly thanks for replying,

You are welcome.
I have a dll that is being called by an app,

A dll is a library that contains functions which may be called (or called
back)
the application may change but my dll will always be called since it is a
system wide hook.

System wide hooks are big hammers. Swing wide of the mark and innocents get
hurt. :-)
I need to know the window caption of the app that loaded my dll.

You write "_the_ window caption" but an application which triggers a hook
may have many windows. Which do you want?

Why not take a step back and describe what you want to do rather than how
you want to do it?

Regards,
Will
 
Hi William,

Yep the dll is a can cause a lot of problems, We are testing it a lot and
hope to resolve most of the issues.
When EnumWindows is used the results are not that accurate and if there are
child windows associated with the application i may get the hwnd of the
child window. if my dll was launched by an exe with the caption "Testing for
HWND". i get the hmodule of this using GetModuleHandle(NULL). if i can get
the caption of this. I will get the hwnd of the parent window using
findwindow and using the caption.

BTW one of the childwindows attached to this application, is attached by my
dll itself..

Regards
Abhishek
 
Abhishek said:
Yep the dll is a can cause a lot of problems, We are testing it a lot and
hope to resolve most of the issues.
Most?

When EnumWindows is used the results are not that accurate

How is it not accurate?
and if there are child windows associated with the application i may get
the hwnd of the child window.

No, it enumerate top-level windows.
if my dll was launched by an exe with the caption "Testing for HWND". i
get the hmodule of this using GetModuleHandle(NULL).
OK.

if i can get the caption of this. I will get the hwnd of the parent window
using findwindow and using the caption.

I explained how to do that in an earlier post. There are other ways to go as
well. The truth is that I am reluctant to explain how to do things which I
fear are too intrusive inside a system-wide hook.

Regards,
Will
 
Hi William

Sorry i got confused to with this. "You write "_the_ window caption" but an
application which triggers a hook.
may have many windows. Which do you want?" This has only one window and
usually one child. the child is an instance of Mozilla that is attached to
this process. I need the title of the parent window. also there will not be
multiple instances of the same parent window.

Regards
Abhishek.
 
Back
Top