Thanks in advance for your time. I'd like to use the WAITFORSINGLEOBJECT API to have VB pause until user logs into a shelled application. According to what I've read in this forum I need to:
SHELL application
OPENPROCESS using shelled application's pid
WAITFORSINGLEOBJECT using handle from OPENPROCESS
CLOSEHANDLE
etc
Since I need the system to pause during the login process , I attempted to use handle for the login window (I get it using GETWINDOW in a loop.) However, VB does not wait :-(. I thought since I already have the login handle, I do not need to OPENPROCESS
I !!. Why is the WAITFORSINGLEOBJECT not pausing the VB:-( ? What am I missingX-) ? Here's sample code:
SHELL application
OPENPROCESS using shelled application's pid
WAITFORSINGLEOBJECT using handle from OPENPROCESS
CLOSEHANDLE
etc
Since I need the system to pause during the login process , I attempted to use handle for the login window (I get it using GETWINDOW in a loop.) However, VB does not wait :-(. I thought since I already have the login handle, I do not need to OPENPROCESS
Code:
Function SomeProcess() As Long
...
varLogName = "Login"
'get login window handle
CurrWndHndl = CheckApp(TaskName, varLogName)
'check results
If CurrWndHndl = 0 Then
MsgBox "Login cancelled.", vbOKOnly, ProcessName
Exit Function
Else
'now wait until user has logged in
lngRetVal = WaitForSingleObject(CurrWndHndl, INFINITE)
End If
...
End Function
Function CheckApp(TaskName As String, ProcessName As String) As Long
...
[b]NOTE: [/b]
Here I get the handle using the window (caption) name. This is working fine as I use the handle at other times in my program without any problems.
...
CheckApp = CurrWndHndl
End Function