1。你可用FindWindows获得另一个程序的句柄,然后调用getwindowtext得到它的标题
2。获得句病,也可用GetDestopWindow()获得桌面句病,再用getwindow获得桌面中启动的线程的句柄,再用GetWindowText()获得你要的标题

解决方案 »

  1.   

    一下是我为了不给老板看见qq消息窗口而写的将qq消息窗口隐藏的小代码你可以参照一下:'''窗体代码:
    Private Sub Command1_Click()
        EnumWindows AddressOf EnumWindowsProc, ByVal 0&End SubPrivate Sub Form_Load()
        Me.AutoRedraw = True
    End Sub'''模块代码:
    'Add this code to a module
    Declare Function EnumWindows Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long) As Boolean
    Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
    Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
    Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
    Public Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
    Public Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
    Public Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As LongPublic Const GW_HWNDFIRST = 0
    Public Const GW_HWNDNEXT = 2
    Public Const SW_HIDE = 0
    Public Const SW_RESTORE = 9
    Public Const WS_EX_LAYERED = &H80000
    Public Const GWL_EXSTYLE = (-20)
    Public Const LWA_ALPHA = &H2
    Public Const LWA_COLORKEY = &H1
    Public Const WS_EX_TOOLWINDOW = &H80
    Public Const WS_EX_APPWINDOW As Long = &H40000Public Function EnumWindowsProc(ByVal hwnd As Long, ByVal lParam As Long) As Boolean
        Dim sSave As String, Ret As Long
        Ret = GetWindowTextLength(hwnd)
        sSave = Space(Ret)
        GetWindowText hwnd, sSave, Ret + 1
        'Form1.Print Str$(hwnd) + " " + sSave
        If InStr(1, sSave, "消息") Then
            MsgBox "find"
            ShowWindow hwnd, SW_HIDE
            
            Dim rtn As Long
            rtn = GetWindowLong(hwnd, GWL_EXSTYLE)
            rtn = rtn Or WS_EX_LAYERED
            rtn = rtn Or WS_EX_TOOLWINDOW
            
            'rtn = rtn And Not WS_EX_APPWINDOW
            SetWindowLong hwnd, GWL_EXSTYLE, rtn
            
            ShowWindow hwnd, SW_RESTORE
            
            SetLayeredWindowAttributes hwnd, 0, 100, LWA_ALPHA
            End
        End If
        'continue enumeration
        EnumWindowsProc = True
        
    End Function
    至于窗体置前,你只要在找到窗体句柄后用 setwindowpos