“我的电脑”的标题可能会改变,比如C盘啊D盘啊而且不能用结束EXPLORER进程

解决方案 »

  1.   

    两种思路:
    1 用findwindow之类的api查找所有顶级窗口,然后根据类名或对应进程信息,判断其是否为需要的窗口,关闭时,用sendmessage发送WM_CLOSE消息即可2 枚举ShellWindows中的窗口,要关闭的时候调用quit方法即可:
    Option Explicit
    '需要引用 Microsoft Internet Controls
    Dim mShellWindows As New ShellWindows
    Private Sub Command1_Click()
        Dim b As InternetExplorer
        For Each b In mShellWindows
            If b.FullName = VBA.Environ$("windir") & "\explorer.exe" Then
            Debug.Print b.LocationName
            End If
        Next
    End SubPrivate Sub Command2_Click()
        '关闭所有符合你要求的窗口
        Dim b As InternetExplorer
        For Each b In mShellWindows
            If b.FullName = VBA.Environ$("windir") & "\explorer.exe" Then
            b.Quit
            End If
        Next
    End Sub
      

  2.   

    2 枚举ShellWindows中的窗口,要关闭的时候调用quit方法即可:
    嘎嘎,今天终于被我看到这个代码了。..............收藏
      

  3.   

    ..........收藏......这Windows里还有太多的秘密......不知道有没有什么书详细讲讲过?
      

  4.   

    我觉得rainstormmaster 的方法不错