2010年7月28日 星期三

FindWindowEx Function

參考1
參考2
----------
_
Private Shared Function FindWindowEx(ByVal parentHandle As IntPtr, _
ByVal childAfter As IntPtr, _
ByVal lclassName As String, _
ByVal windowTitle As String) As IntPtr
End Function

-(1)-
Dim tmpWnd&
tmpWnd = FindWindow("Shell_TrayWnd", "") 'Task bar
tmpWnd = FindWindowEx(tmpWnd, 0&, "TrayNotifyWnd", "") 'System tray
trayClock = FindWindowEx(tmpWnd, 0&, "TrayClockWClass", "") 'System tray clock

-(2)-
Dim tmpWnd&, clsName As String * 100, clsLen&
tmpWnd = FindWindow("Shell_TrayWnd", "") 'Task bar
tmpWnd = FindWindowEx(tmpWnd, 0&, "TrayNotifyWnd", "") 'System tray
trayClock = FindWindowEx(tmpWnd, 0&, "TrayClockWClass", "") 'System tray clock
If trayClock = 0 Then
tmpWnd = GetWindow(tmpWnd, GW_CHILD)
Do While tmpWnd <> 0
clsLen = GetClassName(tmpWnd, clsName, 100)
If Left(clsName, clsLen) = "TrayClockWClass" Then
trayClock = tmpWnd
Exit Do
End If
tmpWnd = GetWindow(tmpWnd, GW_HWNDNEXT)
Loop
End If

-(3)-
ShellTrayWnd& = FindWindow("Shell_TrayWnd", vbNullString)
TrayNotifyWnd& = FindWindowEx(ShellTrayWnd&, 0&, "TrayNotifyWnd", vbNullString)
TrayClockWClass& = FindWindowEx(TrayNotifyWnd&, 0&, "TrayClockWClass", vbNullString)

沒有留言:

張貼留言