' Load the icons.
   MSHFlexGrid1.Row = 1
   MSHFlexGrid1.Col = 1
   Set MSHFlexGrid1.CellPicture = Picture1.Picture

解决方案 »

  1.   

    '关闭程序:
    Option ExplicitDeclare Function EnumWindows Lib "user32" (ByVal wndenmprc As Long, ByVal lParam As Long) As Long
    Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Public Const WM_CLOSE = &H10Private Target As String
    ' Check a returned task to see if we should
    ' kill it.
    Public Function EnumCallback(ByVal app_hWnd As Long, ByVal param As Long) As Long
    Dim buf As String * 256
    Dim title As String
    Dim length As Long    ' Get the window's title.
        length = GetWindowText(app_hWnd, buf, Len(buf))
        title = Left$(buf, length)    ' See if this is the target window.
        If InStr(title, Target) <> 0 Then
            ' Kill the window.
            SendMessage app_hWnd, WM_CLOSE, 0, 0
        End If
        
        ' Continue searching.
        EnumCallback = 1
    End Function' Ask Windows for the list of tasks.
    Public Sub TerminateTask(app_name As String)
        Target = app_name
        EnumWindows AddressOf EnumCallback, 0
    End Sub'调用TerminateTask 窗口文本 可结束程序
    '以下检查程序是否运行
    '在模块中声明:
    Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long'调用:
    Handle = FindWindow(vbNullString, 窗口文本)可以从返回的 Handle 值得知窗口是否在运行,不管窗口是否显示