有人可以解释一下这实际上在做什么吗?

时间:2018-09-10 13:52:04

标签: excel vba excel-vba user32

我一直在寻找一种使用vba关闭Windows资源管理器的方法,并且发现了一些可行的方法。但是我实际上不知道它实际上在做什么,或者它意味着什么。有人可以解释一下下面发生了什么吗?

Private Const CLOSE_WIN = &H10
Dim Hwnd As Long

Private Declare Function apiFindWindow _
    Lib "user32" Alias "FindWindowA" _
    (ByVal lpClassname As String, _
    ByVal lpWindowName As String) _
    As Long

Private Declare Function apiPostMessage _
    Lib "user32" Alias "PostMessageA" _
    (ByVal Hwnd As Long, _
    ByVal wMsg As Long, _
    ByVal wParam As Long, _
    lParam As Any) _
    As Long

    Hwnd = apiFindWindow("CabinetWClass", vbNullString)

    Dim retval As Long
    If (Hwnd) Then
       retval = apiPostMessage(Hwnd, CLOSE_WIN, 0, ByVal 0&)
    End If

谢谢

0 个答案:

没有答案