FindWindow Not Working
Posted on 2004-08-19
In VB.NET, I have the following that SHOULD work...
In the general declarations section of a form:
'Finds a Window based on ClassName or WindowName or Both
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
In the form click event I have the following:
Dim ClassName As String
Dim Caption As String
Dim hWnd As Long
ClassName = "SciCalc"
Caption = "Calculator"
hWnd = FindWindow(ClassName, "")
The problem is that I get a value returned no matter what ! In the example above, I did NOT have the calc running and I still get a value from FindWindow. I should have seen it as ZERO ???
Everything I've seen says this should work. Please help, this is driving me nuts !