请教各位,怎么获得一个标题带文字+"+时间日期的窗体句柄

请问各位,如何获得一个标题带文字+"+时间日期的窗体句柄
这个标题很复杂 总问大家有些不好意思,不过确实很无奈,我都愁死了手头还没有相关的书
G1 "A" "B" "C" SETUP PROGRAM 2010-03-12 08:06:31
时间和日期同步更新
用wnd = FindWindow(vbNullString, "****")好像不能实现吧。

另外我从网上找到一个,控制“按键”的程序:
Private Sub Command1_Click()
hpwnd = FindWindow(vbNullString, "12345")
hcwnd = FindWindowEx(hpwnd, 0, vbNullString, "确定")
SetForegroundWindow hcwnd
iResult = SendMessage(hcwnd, WM_LBUTTONDOWN, 0, 0&)
iResult = SendMessage(hcwnd, WM_LBUTTONUP, 0, 0&)
End Sub
当我Command1_Click时,目标软件确实有反应,但不是按“确定”键操作的反应,只是窗体闪了闪,
正常按“确定”应该弹出msgbox的。
是SendMessage那错了吗?

------解决方案--------------------
发鼠标消息还是用PostMessage吧

VB code
Option Explicit
Const MK_LBUTTON = 1
Private Sub Command1_Click()
Dim hpwnd As Long, hcwnd As Long, iresult As Long
hpwnd = FindWindow(vbNullString, "12345")
hcwnd = FindWindowEx(hpwnd, 0, vbNullString, "确定")
SetForegroundWindow hcwnd
iresult = PostMessage(hcwnd, WM_LBUTTONDOWN, ByVal MK_LBUTTON, ByVal 0&)
iresult = PostMessage(hcwnd, WM_LBUTTONUP, ByVal 0&, ByVal 0&)
End Sub

------解决方案--------------------
掉了一个函数
VB code

'取一个程序的真正根进程Hwnd
Private Function GetRootParent(ByVal hChdWnd As Long) As Long
    Dim lRt     As Long
    Dim lParent As Long
    lRt = GetParent(hChdWnd)
    If lRt = 0 Then
       lRt = GetNextWindow(hChdWnd, GW_OWNER)
    End If
    lParent = lRt
    Do Until lRt = 0
    
        lRt = GetParent(lParent)
        If lRt = 0 Then
           lRt = GetNextWindow(lParent, GW_OWNER)
        End If
        If lRt = 0 Then
            GetRootParent = lParent
            Exit Do
        Else
            lParent = lRt
        End If
    Loop
    If GetRootParent = 0 Then
        GetRootParent = hChdWnd
    End If
End Function

------解决方案--------------------
VB code
'窗体Form1代码
Option Explicit
'窗体上添加一个命令按钮Command1,一个列表框List1
Private Sub Command1_Click()
        EnumWindows AddressOf EnumWindowsProc, ByVal 0&
End Sub

Private Sub Form_Load()

End Sub

'标准模块
Option Explicit

Public Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Boolean
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Boolean
       Dim windowCaption As String, LengthCaption As Long
       LengthCaption = GetWindowTextLength(hwnd)
       windowCaption = Space(LengthCaption)
       Call GetWindowText(hwnd, windowCaption, LengthCaption + 1)
       
       '查找窗口标题包含文字"SETUP PROGRAM"的窗口。这个地方可以自己改。
       If InStr(1, windowCaption, "SETUP PROGRAM") > 0 Then
          Debug.Print "这个句柄就是你要找的:"; hwnd
       End If
       
       Form1.List1.AddItem Str$(hwnd) + "   " + windowCaption
       EnumWindowsProc = True
End Function