• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 259
  • Last Modified:

Experts help!!! FindWindow API function

I want to check if a certain windows explorer window is still open even though it is minimized.
I found this function FindWindow:

Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer

I am calling the window the following way:

handle = FindWindow("explorer", "\\Server03\Test\")

but every time 0 gets returned.
I think the problem is that I am not passing the correct arguments.
What do I pass in place of lpClassName and lpWindowName?


0
YZlat
Asked:
YZlat
  • 7
  • 4
1 Solution
 
Bob LearnedCommented:
1) Is the full window title \\Server03\Test\?

2) The class for explorer is ExploreWClass (found with Spy++)

Bob
0
 
YZlatAuthor Commented:
Thanks Bob, I already resolved it:

handle = FindWindow(vbNullString, "\\Server03\Test\")
worked like a charm
0
 
Bob LearnedCommented:
Yep, that works too.  Just wanted to show you how to find the window class.

Bob
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
YZlatAuthor Commented:
Bob, and what if I want to find my application - MyApp.exe?

I tried:

Handle = FindWindow(vbNullString, "MyApp.exe")

but it didn't work
0
 
YZlatAuthor Commented:
Bob, the funny thing is that

handle = FindWindow("ExploreWClass", "\\Server03\Test\")

did not work
0
 
Bob LearnedCommented:
Would this work?

   handle = FindWindow("ExploreWClass", vbNullString)

Bob
0
 
YZlatAuthor Commented:
but that could return a handle to any explorer window and not to that particular one
0
 
YZlatAuthor Commented:
why doesn't Handle = FindWindow(vbNullString, "MyApp.exe")

work?
0
 
YZlatAuthor Commented:
I tried

Handle = FindWindow(vbNullString, "Window Title")

and it worked
0
 
Bob LearnedCommented:
Does this work?

 handle = FindWindow("ExploreWClass", "Window Title")

Bob
0
 
YZlatAuthor Commented:
nope
0

Featured Post

[Webinar] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 7
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now