Link to home
Start Free TrialLog in
Avatar of RnS
RnS

asked on

Using the "FindWindow" function from the User32.dll

in my prog. , i'm trying to find in run time whether the microsoft word is running already or not, by using the "FindWindow" function from the user32.dll API.
my question is :when i use this function (FindWindow), i must insert as argument the window name i would like the function to search for.
does anynoe know the name of microsoft word, in order the function will tell me if it's already running or not.
Thanks.
ASKER CERTIFIED SOLUTION
Avatar of waty
waty
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of stewfidgeon
stewfidgeon

The name of the window is the text written in the blue title bar at the top of the window.

Note: the full title of the window may change depending on what file you have open.

Ie: Untitled - Notepad may become Myfile - Notepad where MyFile is the name of the file you have open.

Stew.


Doh, Waty answered while I was writing this, oh well. Guess I'll have to learn to type faster :)
May as well post it as a comment, although I'm sure waty's answer will be correct.
Both our answer are correct stewfidgeon, mine is a link to an explanation on how to do the work.

Anyway, here is another link :

"How do I find out if a particular program is running when I don't know the entire window caption?" Ever asked that question? Then this demo Is For you! Provides a custom FindWindowPartial Function that returns the handle of the first window that matches your search criteria. You can search For window captions that start With, Or contain, any substring you wish. Perfect For apps that show both their own Name And the Name of the active document In the titlebar.

Some of the APIs used include EnumWindows, FindWindow, GetWindow, GetWindowText, IsIconic, SetForegroundWindow, ShowWindow And more.

Featured In my Programming Techniques column, VBPJ, September 1995
And Ask the VB Pro column, VBPJ, June 1998.
Provided As VB4-16/32 conditionally-compiled source, And VB5 32-bit.    (7K)

FindPart.zip : http://www.mvps.org/vb/code/FindPart.zip

NB : I use my VBCodeDatabase to respond, it contains lots of useful knowledge, and I can respond to almost arround 60% of questions easily using this :)

Take a look to my web for a shareware version :)
GREETINGS!

This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects the problem and the expert will now receive these points; points verified.

Please click on your Member Profile and select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.  If you are an EE Pro user, you can also choose Power Search to find all your open questions.

This is the Community Support link, if help is needed, along with the link to All Topics which reflects many TAs recently added.

https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
https://www.experts-exchange.com/jsp/zonesAll.jsp
 
Thank you,
Moondancer
Moderator @ Experts Exchange